Comment 7 for bug 95519

Revision history for this message
Reece (reece) wrote :

One way to solve your problem is to set IFS to explicitly cause files to be split on newlines, as below. For an explanation of how this works, see the bash man page. Similar functionality exists in sh and zsh (and probably the csh-derived shells as well).

#!/bin/bash
IFS=$'\n'
for file in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do
 zenity --info --text "$(md5sum $file)"
done

Although quoting in shell scripts is frustrating and obtuse, the behavior you experienced is not a bug. I recommend closing as not-a-bug.

The only misfeature here is that \n is technically legal in filenames; \0 would have been preferable.

I can't resist. Here's a great way to impress people at dinner parties and wow chicks:
#!/bin/bash
IFS=$'\n'
zenity --list --column md5 --column file $(find ${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS} -type f -print0 | xargs -0r md5sum | perl -pe 's/^(\S+)\s\s/$1\n/')

-Reece