View Full Version : Context menu functions - special characters in filenames
Dave_L
13-Jan-2008, 05:27 AM
[Builds 442-443, MEPIS 7.0, KDE 3.5.8]
Re: Context menu functions 'Select Left Side to Compare' and 'Compare To'
I've found that these functions fail to work properly if the directories or filenames contain spaces or other special characters.
One solution I've tried is to enclose each instance of %f in ~/.beyondcompare/context_menu/action with quotes.
That seems to solve the spaces issue, but still fails if the filename ends in a tilde (~). The tilde gets interpreted as the user's home directory.
The problem only occurs with the context menu functions. BC has no problem comparing these items if they're selected from within BC, or if the icons are dragged into BC from Konqueror.
I'll continue working on this, but suggestions are welcome. :)
Jacques
15-Jan-2008, 05:06 PM
I made the following change to the action script to support opening files with spaces in their names via the context menu. Hopefully it works for you.
fi
if [ -n "$LEFTSIDE" ]; then
+ "$BCEXEFILE" "$LEFTSIDE" "$2"
- "$BCEXEFILE" "\"$LEFTSIDE\"" "\"$2\""
fi
;;
The filename parsing has been improved and it can now open files with terminating tildes in their names. Unfortunately these fixes didn't make it into today's release.
Were there any specific special characters that were not working for you. I am aware of some problems involving the '\' and '$' characters. Cirrus now attempts to replace any unescaped dollar sign with an environment variable and KDE apps don't appear to escape the dollar sign.
Dave_L
19-Jan-2008, 01:24 PM
Thanks. I've confirmed that your change fixes the problem with filenames containing spaces.
I haven't noticed issues with other special characters, I only came across the tilde problem because some editors, such as kate, default to using that character when creating file backups.
Jacques
21-Jan-2008, 12:03 PM
I'm glad it works for you. Sorry about the problem with the backups, the only workaround that I can think of is to replace the ~ with .bak or something. You probably already know this but you can easily do that with the rename command, e.g.
$> rename 's/~$/.bak/' *~
or something similar.
SteveCGElliott
06-Aug-2008, 01:17 AM
I have just installed Version 3.0 Build 8507 on RHEL5 and the "spaces in filename" fault seems to be in that version.
Has there been a regression of this previous fix?
Steve
Jacques
06-Aug-2008, 11:29 AM
Can I assume you are using gnome? It appears the gnome context menus never correctly handled filenames with spaces.
To fix this you can replace the following files in ~/.gnome2/nautilus-scripts
compare:
#!/bin/sh
bcompare "$@"
compare_to_selected:
#!/bin/sh
arg2=$(cat $HOME/.beyondcompare/nautilus)
bcompare "$@" $arg2
select_for_compare:
#!/bin/sh
echo "'$@'" > $HOME/.beyondcompare/nautilus
You will also have to replace the similarly named files in /usr/lib/beyondcompare (assuming you used the RPM), since BC will update the context menu scripts every time you run BC. These changes will also be in 3.0.1 if you'd rather wait.
ratol
08-Jan-2009, 04:20 AM
Default scripts seem to miss handling for fully qualified file/folder paths, limiting selections under single parent directory.
I played around with following scripts, and they seem to quote fully qualified paths properly (didn't test special characters besides space, though).
Awk/sed script courtesy of Paolo Bacch, from http://g-scripts.sourceforge.net/faq.php.
compare:
#!/bin/sh
quoted=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | awk 'BEGIN { FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##)
bcompare $quoted
select_for_compare:
#!/bin/sh
quoted=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | awk 'BEGIN { FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##)
echo "$quoted" > $HOME/.beyondcompare/nautilus
compare_to_selected:
#!/bin/sh
arg2=$(cat $HOME/.beyondcompare/nautilus)
arg1=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | awk 'BEGIN { FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##)
bcompare $arg1 $arg2
In addition, it would be nice to have all BC scripts by default in a subdirectory under nautilus-scripts.
I'm using BC 3.0.13 (build 9599).
Craig
04-Feb-2009, 02:45 PM
Hi Ratol,
Thank you for the fixes. We'll add those changes to the next release.
vBulletin® v3.7.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.