Very odd IO problem

All:

I have a very strange problem. I’m hoping someone can help me with
an answer or at least point me in the right direction. I’ve been
plagued with this problem for quite sometime now, however, up until
now it has only been an intermittent problem.

File: [bh.scripts]cwd.rb
print Dir.getwd

p ruby [bh.scripts]cwd.rb.dump
puts ruby [bh.scripts]cwd.rb
Exit
"“D\nS\nA\n0\n:\n[\nB\nH\n]\n”"
D
S
A
0
:
[
B
H
]

Any ideas about how to fix this?

Regards,
Brad

···

A:BH> ruby

All:

···

On Wed, 17 Dec 2003, Brad wrote:

I have a very strange problem. I’m hoping someone can help me with

an answer or at least point me in the right direction. I’ve been

plagued with this problem for quite sometime now, however, up until

now it has only been an intermittent problem.

File: [bh.scripts]cwd.rb

print Dir.getwd

A:BH> ruby

p ruby [bh.scripts]cwd.rb.dump

puts ruby [bh.scripts]cwd.rb

Exit

““D\nS\nA\n0\n:\n[\nB\nH\n]\n””

D

S

A

0

:

[

B

H

]

Any ideas about how to fix this?

What OS is this?

Hi,

···

In message “Very odd IO problem” on 03/12/17, Brad coish@hfx.eastlink.ca writes:

I have a very strange problem. I’m hoping someone can help me with
an answer or at least point me in the right direction. I’ve been
plagued with this problem for quite sometime now, however, up until
now it has only been an intermittent problem.

Hmm, it seems working pretty as I expect. What’s your problem?
I mean, what do you expect from it?

						matz.

Hi,

···

At Wed, 17 Dec 2003 10:21:57 +0900, Brad wrote:

I have a very strange problem. I’m hoping someone can help me with
an answer or at least point me in the right direction. I’ve been
plagued with this problem for quite sometime now, however, up until
now it has only been an intermittent problem.

File: [bh.scripts]cwd.rb
print Dir.getwd

At first, this script works correctly? Which do you have the
problem, with Dir.getwd only or with backticks?

Anyhow, perhaps VMS style path names would cause many problems
at File.dirname etc.

Index: util.c

RCS file: /cvs/ruby/src/ruby/util.c,v
retrieving revision 1.38
diff -u -2 -p -r1.38 util.c
— util.c 22 Nov 2003 03:59:18 -0000 1.38
+++ util.c 17 Dec 2003 03:11:48 -0000
@@ -638,4 +638,8 @@ ruby_getcwd()
{
#ifdef HAVE_GETCWD
+# ifdef __VMS

  • char *buf = getcwd(NULL, 0, 0);
  • if (!buf) rb_sys_fail(“getcwd”);
    +# else
    int size = 200;
    char *buf = xmalloc(size);
    @@ -646,4 +650,5 @@ ruby_getcwd()
    buf = xrealloc(buf, size);
    }
    +# endif
    #else

ifndef PATH_MAX


Nobu Nakada

Chad Fowler wrote:

···

On Wed, 17 Dec 2003, Brad wrote:

All:

I have a very strange problem. I’m hoping someone can help me with

an answer or at least point me in the right direction. I’ve been

plagued with this problem for quite sometime now, however, up until

now it has only been an intermittent problem.

File: [bh.scripts]cwd.rb

print Dir.getwd

A:BH> ruby

p ruby [bh.scripts]cwd.rb.dump

puts ruby [bh.scripts]cwd.rb

Exit

“"D\nS\nA\n0\n:\n[\nB\nH\n]\n"”

D

S

A

0

:

[

B

H

]

Any ideas about how to fix this?

What OS is this?

Sorry, I should have mentioned that. :slight_smile:
OpenVMS on Alpha system.

Regards,
Brad

Hi,

···

In message “Re: Very odd IO problem” on 03/12/17, Yukihiro Matsumoto matz@ruby-lang.org writes:

I have a very strange problem. I’m hoping someone can help me with
an answer or at least point me in the right direction. I’ve been
plagued with this problem for quite sometime now, however, up until
now it has only been an intermittent problem.

Hmm, it seems working pretty as I expect. What’s your problem?
I mean, what do you expect from it?

Oops, I was looking at the second part. You were talking about getwd.
Sorry. But It seems like it’s a problem in the VMS port which I don’t
know.

						matz.

Nobu:

Thanks for the response! I applied the specified patch to util.c
however, it doesn’t seem to have made a difference. Dir.getwd works
ok, I think the problem is in the ``. I’ll keep looking and if I find
something I will be sure to post the fix.

I will remain open to suggestions as I’ve hunted this problem off and on
for quite awhile. Any suggestions are appreciated.

Regards,
Brad

···

nobu.nokada@softhome.net wrote:

Hi,

At Wed, 17 Dec 2003 10:21:57 +0900, > Brad wrote:

I have a very strange problem. I’m hoping someone can help me with
an answer or at least point me in the right direction. I’ve been
plagued with this problem for quite sometime now, however, up until
now it has only been an intermittent problem.

File: [bh.scripts]cwd.rb
print Dir.getwd

At first, this script works correctly? Which do you have the
problem, with Dir.getwd only or with backticks?

Anyhow, perhaps VMS style path names would cause many problems
at File.dirname etc.

Index: util.c

RCS file: /cvs/ruby/src/ruby/util.c,v
retrieving revision 1.38
diff -u -2 -p -r1.38 util.c
— util.c 22 Nov 2003 03:59:18 -0000 1.38
+++ util.c 17 Dec 2003 03:11:48 -0000
@@ -638,4 +638,8 @@ ruby_getcwd()
{
#ifdef HAVE_GETCWD
+# ifdef __VMS

  • char *buf = getcwd(NULL, 0, 0);
  • if (!buf) rb_sys_fail(“getcwd”);
    +# else
    int size = 200;
    char *buf = xmalloc(size);
    @@ -646,4 +650,5 @@ ruby_getcwd()
    buf = xrealloc(buf, size);
    }
    +# endif
    #else

ifndef PATH_MAX

Yukihiro Matsumoto wrote:

Hi,

I have a very strange problem. I’m hoping someone can help me with
an answer or at least point me in the right direction. I’ve been
plagued with this problem for quite sometime now, however, up until
now it has only been an intermittent problem.

Hmm, it seems working pretty as I expect. What’s your problem?
I mean, what do you expect from it?

Oops, I was looking at the second part. You were talking about getwd.
Sorry. But It seems like it’s a problem in the VMS port which I don’t
know.

                                                   matz.

matz:

Thanks for the reply! I was hoping that it wasn’t a VMS only problem.
:slight_smile:

I guess I’ll keep trying until I find the source of the problem, or
until someone has an idea to try.

Your response is greatly appreciated. :slight_smile:

One last question:
With what I have shown, is there anything that comes to mind that may
be suspect? Any bit of information that could narrow my search would
be great.

If not, thanks for trying. :slight_smile:

Regards,
Brad

···

In message “Re: Very odd IO problem” > on 03/12/17, Yukihiro Matsumoto matz@ruby-lang.org writes:

Hi,

Thanks for the response! I applied the specified patch to util.c
however, it doesn’t seem to have made a difference. Dir.getwd works
ok, I think the problem is in the ``. I’ll keep looking and if I find
something I will be sure to post the fix.

I know the previous patch wouldn’t fix the odd behavior, since
it was just for the style of returned value from Dir.getwd.

I doubt that it might be concerned with READ_DATA_PENDING(),
READ_DATA_BUFFERED() etc, however, it would need more
investigation.

  • Does File.read method work correctly?
  • That behavior occurs with pipe?
···

At Wed, 17 Dec 2003 21:07:00 +0900, Brad wrote:


Nobu Nakada

Brad wrote:

Thanks for the reply! I was hoping that it wasn’t a VMS only problem.

Directories on VMS are quite odd to those from a MSDOS or Unix world.
In particular, the name of a directory is quite different from the name
of the file containing the directory. I have several hundred lines of C
code somewhere here that does various operations on OpenVMS directories.
To get the directory filename from the directory name you have to handle
the following transformations:
x.y cwd.dir

···

a:x.y a:000000.dir
x.y cwd.dir
a:x.y a:000000.dir
[d]x.y [000000]d.dir
a:[d]x.y a:[000000]d.dir
[d.e]x.y [d]e.dir
a:[d.e]x.y a:[d]e.dir

Ugly, but I’m not familiar with how Ruby deals with it.

This message has been automatically forwarded from the ruby-talk mailing list by a gateway at pragprog.com. If it is SPAM, it did not originate at pragprog.com. Please report the original sender, and not us. Thanks! wrote:

Hi,

Thanks for the response! I applied the specified patch to util.c
however, it doesn’t seem to have made a difference. Dir.getwd works
ok, I think the problem is in the ``. I’ll keep looking and if I find
something I will be sure to post the fix.

I know the previous patch wouldn’t fix the odd behavior, since
it was just for the style of returned value from Dir.getwd.

I doubt that it might be concerned with READ_DATA_PENDING(),
READ_DATA_BUFFERED() etc, however, it would need more
investigation.

  • Does File.read method work correctly?
  • That behavior occurs with pipe?

Nobu:

I tried using File.read and it worked successfully.
I have also made other experiments which lead me to believe that pipes
work as expected:

perl cwd.prl ==> Worked correctly
@[]cwd.com ==> Worked correctly (VMS .com files are akin to
.BAT files on MS-DOS)

I’ve also tried using miniruby and wrapping the call to the ruby script
in perl and DCL (.com file), each of which returned the output:

C==character of a path

C\nC\nC\n

which prints as one would expect:

C
C
C

It seems only to occur when I invoke ruby from ruby.

Regards,
Brad

···

At Wed, 17 Dec 2003 21:07:00 +0900, > Brad wrote:

Clifford Heath wrote:

Brad wrote:

Thanks for the reply! I was hoping that it wasn’t a VMS only problem.

Directories on VMS are quite odd to those from a MSDOS or Unix world.
In particular, the name of a directory is quite different from the name
of the file containing the directory. I have several hundred lines of C
code somewhere here that does various operations on OpenVMS directories.
To get the directory filename from the directory name you have to handle
the following transformations:
x.y cwd.dir
a:x.y a:000000.dir
x.y cwd.dir
a:x.y a:000000.dir
[d]x.y [000000]d.dir
a:[d]x.y a:[000000]d.dir
[d.e]x.y [d]e.dir
a:[d.e]x.y a:[d]e.dir

Ugly, but I’m not familiar with how Ruby deals with it.

Clifford:

Thanks for the response! For the most part ruby handles VMS paths
pretty well. I had to make a few tweaks, likely with more on the
way. But the problem is not with the directory…unfortunatly. :slight_smile:

I know this because, if I run

ruby -e “print Dir.getwd”

The directory will be printed correctly.

I believe the problem lies in the implementation of the and the communication between the main ruby program and the invoked ruby program (via the).

Regards,
Brad

Hi,

···

In message “Re: Very odd IO problem” on 03/12/17, Brad BCoish@Dymaxion.com writes:

I believe the problem lies in the implementation of the and the communication between the main ruby program and the invoked ruby program (via the).

How does the following work?

ruby -e ‘puts ruby -e "print "hello"

						matz.

Yukihiro Matsumoto wrote:

ruby -e ‘puts ruby -e "print "hello"

matz:

I tried the above example, but it has a syntax error, 3 ".
So, I tried adding a fourth " to balance out the quoting,
ruby didn’t complain, but nothing was displayed either.

I also tried a variation on this:

ruby -e ‘puts ruby -e "puts(4)"

I think it failed because of the way command line arguments
are parsed. Interesting fact: command line parsing must be
be written by the programmer on VMS. i.e. expanding wild cards
is not automatically handled by the command line interpreter.
The quotes must not have been handled properly; I’ll have to
look into this.

E.g. for ruby to handle

ruby.exe script.rb *.c

I had to implement processing of wild cards; Perl on VMS also
shares this fate. I know Perl shares this fate because I based
my command line parsing code on Perls. :confused:

Hopefully this hasn’t been too convoluted.

Regards,
Brad

Hi,

I tried the above example, but it has a syntax error, 3 ".
So, I tried adding a fourth " to balance out the quoting,
ruby didn’t complain, but nothing was displayed either.

Oops, sorry.

I also tried a variation on this:

ruby -e ‘puts ruby -e "puts(4)"

I think it failed because of the way command line arguments
are parsed. Interesting fact: command line parsing must be
be written by the programmer on VMS. i.e. expanding wild cards
is not automatically handled by the command line interpreter.
The quotes must not have been handled properly; I’ll have to
look into this.

How about replacing Dir.getcwd in the first example with

print “hello”

i.e.

File: [bh.scripts]cwd.rb
print “hello”

p ruby [bh.scripts]cwd.rb.dump
puts ruby [bh.scripts]cwd.rb

can you try?

						matz.
···

In message “Re: Very odd IO problem” on 03/12/18, Brad BCoish@Dymaxion.com writes:
A:BH> ruby

This message has been automatically forwarded from the ruby-talk mailing list by a gateway at pragprog.com. If it is SPAM, it did not originate at pragprog.com. Please report the original sender, and not us. Thanks! wrote:

puts ruby [bh.scripts]cwd.rb

matz:

No problem. I tried what you asked and here is the
output:

CWD.RB:
print “hello”

p ruby [bh.scripts]cwd.rb.dump
puts ruby [bh.scripts]cwd.rb
Exit
“"h\ne\nl\nl\no\n"”
h
e
l
l
o

Regards,
Brad

···

A:BH.SCRIPTS> ruby

Hi,

No problem. I tried what you asked and here is the
output:

Thank you. Do me one more favor.

s = open(“|ruby [bh.scripts]cwd.rb”).read
p s
puts s

···

In message “Re: Very odd IO problem” on 03/12/18, Brad BCoish@Dymaxion.com writes:
A:BH.SCRIPTS> ruby

						matz.

Yukihiro Matsumoto wrote:

s = open(“|ruby [bh.scripts]cwd.rb”).read
p s
puts s

matz:

Ok, here it is:

···

A:175000> ruby
s = open(“|ruby [bh.scripts]cwd.rb”).read
p s
puts s
Exit
“h\ne\nl\nl\no\n”
h
e
l
l
o
A:175000>

Your help is greatly appreciated. :slight_smile:

Regards,
Brad