|
From: Scott W. <sw...@ch...> - 2008-02-15 23:54:36
|
Why are data files required to be regular files or pipes? There's a S_ISREG or S_ISFIFO check performed in src/datafile.c around line 1303. I often use bash's <() process substitution syntax to generate data to plot. This works great in GNU/Linux, and worked in FreeBSD, OpenBSD, and NetBSD with bash versions less than 3.2. Starting with bash 3.2.0, bash uses /dev/fd/63 and similar for these substitutions. In Linux, these "devices" are pipes -- they are S_ISFIFO. In *BSD, they are character devices -- S_ISCHR. What is the S_ISREG or S_ISFIFO test for, anyway? It's been in gnuplot since the sourceforge cvs import (rev 1.1, 1999), so there's no commit log there to explain the reason for adding it. Also, the test is simply skipped ifndef HAVE_SYS_STAT_H. Removing the test from gnuplot allowed my graphing scripts to work in *BSD again. |
|
From: Hans-Bernhard B. <HBB...@t-...> - 2008-02-16 20:56:35
|
Scott Worley wrote:
> Why are data files required to be regular files or pipes?
Because the source says so. ;-)
> What is the S_ISREG or S_ISFIFO test for, anyway? It's been in gnuplot
> since the sourceforge cvs import (rev 1.1, 1999), so there's no commit
> log there to explain the reason for adding it.
But there's a ChangeLog entry for it, in the "old" logfile:
1998-09-16 Lars Hecking <lhe...@nm...>
* datafile.c: Modified version of Alexander Mai's stat(2) patch
(check if regular file or pipe before opening data file).
Good luck trying to find Alexander and getting him to remember what his
rationale for that patch was, over nine years ago.
> Also, the test is simply skipped ifndef HAVE_SYS_STAT_H.
Of course it is --- without that header, we can't use stat(), so there
would be no way to do the test.
|
|
From: Lars H. <lhe...@us...> - 2008-02-16 21:31:04
|
> 1998-09-16 Lars Hecking <lhe...@nm...> > > * datafile.c: Modified version of Alexander Mai's stat(2) patch > (check if regular file or pipe before opening data file). > > Good luck trying to find Alexander and getting him to remember what his > rationale for that patch was, over nine years ago. I can't find the actual patch, nor can I find a complete info-gnuplot-beta archive here, but the rationale was simply to avoid opening objects that don't make sense in the context, e.g. directories. So, if there can be a more elegant or general solution, no problem. |
|
From: Ethan A M. <merritt@u.washington.edu> - 2008-02-17 07:13:38
|
On Friday 15 February 2008 15:54, Scott Worley wrote:
> Why are data files required to be regular files or pipes?
I don't know.
> There's a S_ISREG or S_ISFIFO check performed in src/datafile.c around
> line 1303.
>
> I often use bash's <() process substitution syntax to generate data to
> plot.
I do not quite follow what you mean. Could you please provide an example
set of commands? The thing that confuses me is that if you type a
command like
plot '< (grep toe ~/aardvarks)' using lines
it should work without passing through the code at line 1303,
because the '<' is trapped as a special case and treated separately
(line 1276).
To prove the point, here is the output from a stupid test run:
gnuplot> plot '/dev/null'
^
"/dev/null" is not a regular file or pipe
util.c: Success
gnuplot> plot '< (cat /dev/null)'
^
warning: Skipping data file with no valid points
^
x range is invalid
> This works great in GNU/Linux, and worked in FreeBSD, OpenBSD,
> and NetBSD with bash versions less than 3.2. Starting with bash 3.2.0,
> bash uses /dev/fd/63 and similar for these substitutions. In Linux,
> these "devices" are pipes -- they are S_ISFIFO. In *BSD, they are
> character devices -- S_ISCHR.
>
> What is the S_ISREG or S_ISFIFO test for, anyway? It's been in gnuplot
> since the sourceforge cvs import (rev 1.1, 1999), so there's no commit
> log there to explain the reason for adding it. Also, the test is simply
> skipped ifndef HAVE_SYS_STAT_H.
>
>
> Removing the test from gnuplot allowed my graphing scripts to work in
> *BSD again.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> gnuplot-beta mailing list
> gnu...@li...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
>
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742
|
|
From: Scott W. <sw...@ch...> - 2008-02-17 10:22:13
|
>> I often use bash's <() process substitution syntax to generate data to >> plot. > > I do not quite follow what you mean. Could you please provide an example > set of commands? A simple example: gnuplot <<< 'plot "'<(echo -e '1\n3\n2')'" with lines; pause 10' |
|
From: Ethan A M. <merritt@u.washington.edu> - 2008-02-17 15:44:23
|
On Sunday 17 February 2008 02:22, Scott Worley wrote: > gnuplot <<< 'plot "'<(echo -e '1\n3\n2')'" with lines; pause 10' Which one of those two redirections is causing the error? -- Ethan A Merritt Biomolecular Structure Center University of Washington, Seattle 98195-7742 |
|
From: Scott W. <sw...@ch...> - 2008-02-17 16:38:39
|
Ethan A Merritt wrote:
> On Sunday 17 February 2008 02:22, Scott Worley wrote:
>> gnuplot <<< 'plot "'<(echo -e '1\n3\n2')'" with lines; pause 10'
>
> Which one of those two redirections is causing the error?
The <() redirection. The above effectively becomes
gnuplot <<< 'plot "/dev/fd/63" with lines; pause 10'
(as demonstrated by replacing "gnuplot" with "cat":
$ cat <<< 'plot "'<(echo -e '1\n3.5\n2')'" with lines; pause 10'
plot "/dev/fd/63" with lines; pause 10
$ ls -l <( echo foo )
crw-rw-rw- 1 root wheel 22, 63 Sep 23 2005 /dev/fd/63
) and then gnuplot refuses to read from /dev/fd/63 because it's neither
a file nor a pipe in *BSD.
This syntax used to work because in earlier versions of bash <() was
implemented with named pipes in /tmp. Under bash 3.1:
$ cat <<< 'plot "'<(echo -e '1\n3.5\n2')'" with lines; pause 10'
plot "/var/tmp//sh-np-3368567213" with lines; pause 10
$ ls -l <( echo foo )
prw------- 1 chkno wheel 0 Feb 17 08:34 /var/tmp//sh-np-1203260826
|
|
From: Scott W. <sw...@ch...> - 2008-02-17 21:44:50
|
> Scott, can you compile your own with this change to datafile.c: replace
> the code around line 1293
>
> !S_ISREG(statbuf.st_mode) && !S_ISFIFO(statbuf.st_mode)) {
>
> with
>
> S_ISDIR(statbuf.st_mode)) {
>
> and test?
- !S_ISREG(statbuf.st_mode) && !S_ISFIFO(statbuf.st_mode)) {
- os_error(name_token, "\"%s\" is not a regular file or pipe",
+ S_ISDIR(statbuf.st_mode)) {
+ os_error(name_token, "\"%s\" is a directory",
works for me.
|
|
From: Lars H. <lhe...@us...> - 2008-02-18 16:49:53
|
> - !S_ISREG(statbuf.st_mode) && !S_ISFIFO(statbuf.st_mode)) {
> - os_error(name_token, "\"%s\" is not a regular file or pipe",
> + S_ISDIR(statbuf.st_mode)) {
> + os_error(name_token, "\"%s\" is a directory",
>
> works for me.
Ok. I have committed this to cvs, but am still uncertain whether we should
explicitly disallow block devices.
|