Subject: | zenity-2.16.0 returns improperly formatted output |
Hello!
We're using UI-Dialog-1.08 on RHEL 4 and RHEL 5. We only see this bug
on RHEL 5 with zenity-2.16.0-2.el5 and perl 5.8.8 (both vendor-supplied).
In brief, zenity adds an extra backslash before the '\n' used as a
separator by UI-Dialog, and thus when multiple items are selected in a
checklist, UI-Dialog fails to correctly parse them into separate selections.
Steps to reproduce:
1. Run the attached 'zenitytest.pl' and click "OK".
Expected result:
@selected = (
'foo',
'bar'
);
Actual result:
@selected = (
'foo\\nbar'
);
Suggested resolution:
After discussion with Kha Do, a Red Hat engineer, I patched UI-Dialog to
call zenity with --separator $'\n' instead of --separator "\n". This
change preserves the desired behavior and works on both platforms.
The Advanced Bash Scripting guide has some further treatment of this
escaping method (which apparently imposes a dependancy on bash 2 :( ) here:
http://tldp.org/LDP/abs/html/escapingsection.html
Attached is the trivial patch; please consider it for a future release
of UI-Dialog.
thanks,
-Steve Huff
Subject: | UI-Dialog-separator.patch |
diff -Naur UI-Dialog-1.08-orig/lib/UI/Dialog/Backend/Zenity.pm UI-Dialog-1.08/lib/UI/Dialog/Backend/Zenity.pm
--- UI-Dialog-1.08-orig/lib/UI/Dialog/Backend/Zenity.pm 2004-10-03 23:19:29.000000000 -0400
+++ UI-Dialog-1.08/lib/UI/Dialog/Backend/Zenity.pm 2008-04-22 10:32:13.000000000 -0400
@@ -364,7 +364,7 @@
my $command = $self->_mk_cmnd(" --list",$args);
$command .= ($args->{'checklist'}) ? ' --checklist' : ($args->{'radiolist'}) ? ' --radiolist' : "";
- $command .= ' --separator "\n"';
+ $command .= ' --separator $\'\n\'';
#: not quite sure how to implement the editability...
# $command .= ' --editable' unless not $args->{'editable'};
#: --text is not implemented for list widgets, yet...
Subject: | zenitytest.pl |
#!/usr/bin/perl
#
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Purity = 1;
use UI::Dialog;
my $d = new UI::Dialog ( backtitle => 'Separator test',
title => 'Testing',
height => 20,
width => 65,
listheight => 5,
);
my( @selected ) = $d->checklist( text => 'Select:',
list => [ 'foo', [ 'foo', 0 ],
'bar', [ 'bar', 0 ],
],
);
print Data::Dumper->Dump( [ \@selected ], [qw(*selected)] );