Fix quote and output bugs in the gdialog wrapper #128149.
2003-12-02 Christian Mnneckes < c-w-m@gmx.de> * src/gdialog.in: Fix quote and output bugs in the gdialog wrapper #128149.
This commit is contained in:
parent
938257ee65
commit
0ca6b6fe82
@ -1,3 +1,8 @@
|
|||||||
|
2003-12-02 Christian Mönneckes < c-w-m@gmx.de>
|
||||||
|
|
||||||
|
* src/gdialog.in: Fix quote and output bugs
|
||||||
|
in the gdialog wrapper #128149.
|
||||||
|
|
||||||
2003-11-12 Glynn Foster <glynn.foster@sun.com>
|
2003-11-12 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
* src/gdialog.in: Fix radiolist returning the
|
* src/gdialog.in: Fix radiolist returning the
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# unclear is what is a gdialog/zenity translation problem, and what is
|
# unclear is what is a gdialog/zenity translation problem, and what is
|
||||||
# a problem with the original script
|
# a problem with the original script
|
||||||
|
|
||||||
my $command = "zenity "; # the command line we build up to execute
|
my @command = ("zenity"); # the command line we build up to execute
|
||||||
my $element = ""; # current bit of command line
|
my $element = ""; # current bit of command line
|
||||||
my $argn = 0; # counter for walking args
|
my $argn = 0; # counter for walking args
|
||||||
my $args = $#ARGV + 1; # total number of command line arguments
|
my $args = $#ARGV + 1; # total number of command line arguments
|
||||||
@ -33,7 +33,7 @@ unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) {
|
|||||||
|
|
||||||
# reset the command string
|
# reset the command string
|
||||||
|
|
||||||
$command = "";
|
@command = ();
|
||||||
|
|
||||||
# examine all the available/default paths
|
# examine all the available/default paths
|
||||||
|
|
||||||
@ -50,14 +50,14 @@ unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) {
|
|||||||
# as such is the preference over using the "regular"
|
# as such is the preference over using the "regular"
|
||||||
# dialog interface.
|
# dialog interface.
|
||||||
|
|
||||||
$command = $PATH."/gdialog.real ";
|
@command = ($PATH."/gdialog.real");
|
||||||
last BIN;
|
last BIN;
|
||||||
|
|
||||||
} elsif (-x $PATH."/dialog") {
|
} elsif (-x $PATH."/dialog") {
|
||||||
|
|
||||||
# change the command and skip ahead!
|
# change the command and skip ahead!
|
||||||
|
|
||||||
$command = $PATH."/dialog ";
|
@command = ($PATH."/dialog");
|
||||||
last BIN;
|
last BIN;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ($command) {
|
unless (@command) {
|
||||||
|
|
||||||
# we didn't find the dialog binary, exit(254) with a message
|
# we didn't find the dialog binary, exit(254) with a message
|
||||||
# to STDERR.
|
# to STDERR.
|
||||||
@ -86,11 +86,11 @@ unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) {
|
|||||||
# so join the arguments double-quoting things so that proper shell
|
# so join the arguments double-quoting things so that proper shell
|
||||||
# notation is saved.
|
# notation is saved.
|
||||||
|
|
||||||
$command .= '"'.join('" "',@ARGV).'"';
|
push @command, @ARGV;
|
||||||
|
|
||||||
# and fork the process
|
# and fork the process
|
||||||
|
|
||||||
exec($command);
|
exec(@command);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ ARG: while ($argn < $args) {
|
|||||||
|
|
||||||
$argn++;
|
$argn++;
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "--title=\"$element\" ";
|
push @command, "--title=$element";
|
||||||
|
|
||||||
# keep processing args
|
# keep processing args
|
||||||
$argn++;
|
$argn++;
|
||||||
@ -157,7 +157,7 @@ ARG: while ($argn < $args) {
|
|||||||
|
|
||||||
$argn++;
|
$argn++;
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "--info --text=\"$element\" ";
|
push @command, "--info", "--text=$element";
|
||||||
|
|
||||||
# this also happens a lot - gdialog accepted size args
|
# this also happens a lot - gdialog accepted size args
|
||||||
# for dialog compatability - which it pretty much ignored
|
# for dialog compatability - which it pretty much ignored
|
||||||
@ -175,33 +175,33 @@ ARG: while ($argn < $args) {
|
|||||||
|
|
||||||
$argn++;
|
$argn++;
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "--question --text=\"$element\" ";
|
push @command, "--question", "--text=$element";
|
||||||
last ARG;
|
last ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($element eq "--inputbox") {
|
if ($element eq "--inputbox") {
|
||||||
$argn++;
|
$argn++;
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "--entry --text=\"$element\" ";
|
push @command, "--entry", "--text=$element";
|
||||||
|
|
||||||
# ignore size elements and maybe there is some
|
# ignore size elements and maybe there is some
|
||||||
# default text to initialize the entry with?
|
# default text to initialize the entry with?
|
||||||
|
|
||||||
$argn+=3;
|
$argn+=3;
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "--entry-text=\"$element\" ";
|
push @command, "--entry-text=$element";
|
||||||
last ARG;
|
last ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($element eq "--textbox") {
|
if ($element eq "--textbox") {
|
||||||
$command .= "--text-info ";
|
push @command, "--text-info";
|
||||||
|
|
||||||
# the arg immediately following the dialog type in
|
# the arg immediately following the dialog type in
|
||||||
# gdialog is the filename, so pass this to zenity
|
# gdialog is the filename, so pass this to zenity
|
||||||
|
|
||||||
$argn++;
|
$argn++;
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "--filename=\"$element\" ";
|
push @command, "--filename=$element";
|
||||||
|
|
||||||
# width and height matter for this one, so get them
|
# width and height matter for this one, so get them
|
||||||
# and apply the same multipliers as used in gdialog
|
# and apply the same multipliers as used in gdialog
|
||||||
@ -209,11 +209,11 @@ ARG: while ($argn < $args) {
|
|||||||
$argn++;
|
$argn++;
|
||||||
get_arg;
|
get_arg;
|
||||||
$element = $element * 7;
|
$element = $element * 7;
|
||||||
$command .= "--height=\"$element\" ";
|
push @command, "--height=$element";
|
||||||
$argn++;
|
$argn++;
|
||||||
get_arg;
|
get_arg;
|
||||||
$element = $element * 8;
|
$element = $element * 8;
|
||||||
$command .= "--width=\"$element\" ";
|
push @command, "--width=$element";
|
||||||
last ARG;
|
last ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,11 +227,11 @@ ARG: while ($argn < $args) {
|
|||||||
# an untitled column for the check or radio buttons
|
# an untitled column for the check or radio buttons
|
||||||
# and the 'text' arg as a second column header
|
# and the 'text' arg as a second column header
|
||||||
|
|
||||||
$command .= "--list $list --column='' --column='' --column \"$element\" ";
|
push @command, "--list", $list, "--column=''", "--column=''", "--column", $element;
|
||||||
|
|
||||||
# should output be line by line?
|
# should output be line by line?
|
||||||
if ($separator) {
|
if ($separator) {
|
||||||
$command .= " --separator='\n' ";
|
push @command, "--separator=\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Skip to the first 'item' arg of the list content
|
# Skip to the first 'item' arg of the list content
|
||||||
@ -248,10 +248,10 @@ ARG: while ($argn < $args) {
|
|||||||
|
|
||||||
while ($argn < $args) {
|
while ($argn < $args) {
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "NULL \"$element\" ";
|
push @command, "NULL", $element;
|
||||||
$argn += 1;
|
$argn += 1;
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "\"$element\" ";
|
push @command, $element;
|
||||||
$argn += 2;
|
$argn += 2;
|
||||||
}
|
}
|
||||||
last ARG;
|
last ARG;
|
||||||
@ -267,7 +267,7 @@ ARG: while ($argn < $args) {
|
|||||||
# Use the 'text' arg as a second column header
|
# Use the 'text' arg as a second column header
|
||||||
# FIXME: or should it be the dialog text, or both?
|
# FIXME: or should it be the dialog text, or both?
|
||||||
|
|
||||||
$command .= "--list --column '' --column \"$element\" ";
|
push @command, "--list", "--column", "", "--column", $element;
|
||||||
|
|
||||||
# Skip to the first 'item' arg of the list content
|
# Skip to the first 'item' arg of the list content
|
||||||
# after using height, width and bypassing list-height
|
# after using height, width and bypassing list-height
|
||||||
@ -281,7 +281,7 @@ ARG: while ($argn < $args) {
|
|||||||
# per list entry (default font), and 103 pixels for non-list
|
# per list entry (default font), and 103 pixels for non-list
|
||||||
# This appears to be almost exact
|
# This appears to be almost exact
|
||||||
$element = $element*24 - 35;
|
$element = $element*24 - 35;
|
||||||
$command .= " --height $element";
|
push @command, "--height", $element;
|
||||||
|
|
||||||
$argn += 1;
|
$argn += 1;
|
||||||
get_arg;
|
get_arg;
|
||||||
@ -289,7 +289,7 @@ ARG: while ($argn < $args) {
|
|||||||
# per character (default font), and 22 pixels for non-list
|
# per character (default font), and 22 pixels for non-list
|
||||||
# This is not exact, but close enough
|
# This is not exact, but close enough
|
||||||
$element = $element*7 - 20;
|
$element = $element*7 - 20;
|
||||||
$command .= " --width $element " ;
|
push @command, "--width", $element;
|
||||||
|
|
||||||
$argn += 2;
|
$argn += 2;
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ ARG: while ($argn < $args) {
|
|||||||
|
|
||||||
while ($argn < $args) {
|
while ($argn < $args) {
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "$element ";
|
push @command, $element;
|
||||||
$argn += 1;
|
$argn += 1;
|
||||||
}
|
}
|
||||||
last ARG;
|
last ARG;
|
||||||
@ -308,7 +308,7 @@ ARG: while ($argn < $args) {
|
|||||||
if ($element eq "--gauge") {
|
if ($element eq "--gauge") {
|
||||||
$argn++;
|
$argn++;
|
||||||
get_arg;
|
get_arg;
|
||||||
$command .= "--progress --text=\"$element\" ";
|
push @command, "--progress", "--text=$element";
|
||||||
|
|
||||||
# discard the size args as usually, and see if
|
# discard the size args as usually, and see if
|
||||||
# a percentage value was supplied to initialize the
|
# a percentage value was supplied to initialize the
|
||||||
@ -317,7 +317,7 @@ ARG: while ($argn < $args) {
|
|||||||
$argn += 3;
|
$argn += 3;
|
||||||
get_arg;
|
get_arg;
|
||||||
if ($element) {
|
if ($element) {
|
||||||
$command .= "--percentage=$element ";
|
push @command, "--percentage=$element";
|
||||||
}
|
}
|
||||||
last ARG;
|
last ARG;
|
||||||
}
|
}
|
||||||
@ -325,12 +325,29 @@ ARG: while ($argn < $args) {
|
|||||||
$argn++;
|
$argn++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# save STDOUT and STDERR
|
||||||
|
open(ORG_STDOUT, ">&STDOUT");
|
||||||
|
open(ORG_STDERR, ">&STDERR");
|
||||||
|
|
||||||
|
# redirect STDERR to /dev/null (GTK messages ie:
|
||||||
|
# (zenity:637): Gtk-WARNING **: Unable to locate theme engine in module_path: "mist",)
|
||||||
|
open(STDERR, ">/dev/null");
|
||||||
|
|
||||||
|
# redirect STDOUT to STDERR (gdialog direct output to STDERR by default)
|
||||||
|
open(STDOUT, ">&ORG_STDERR");
|
||||||
|
|
||||||
# execute the constructed zenity command line
|
# execute the constructed zenity command line
|
||||||
$command .= " 2>&1";
|
|
||||||
|
|
||||||
# perl doc: The return value of system() is the exit status of the
|
# perl doc: The return value of system() is the exit status of the
|
||||||
#program as returned by the wait() call. To get the actual exit value
|
#program as returned by the wait() call. To get the actual exit value
|
||||||
# divide by 256.
|
# divide by 256.
|
||||||
|
|
||||||
exit(system($command)/256);
|
my $return = system(@command)/256;
|
||||||
|
|
||||||
|
# restore STDOUT and STDERR
|
||||||
|
open(STDOUT, ">&ORG_STDOUT");
|
||||||
|
open(STDERR, ">&ORG_STDERR");
|
||||||
|
close(ORG_STDOUT);
|
||||||
|
close(ORG_STDERR);
|
||||||
|
|
||||||
|
exit $return;
|
||||||
|
Reference in New Issue
Block a user