Unless someone comes up with a unix insight you have indicated what I feared I must do. That is, iterate ARGV[0] that has no / over each path in PATH. The source code for which does this but it is unbelievably complicated and convoluted as it seems to deal with many issues that probably disappeared years ago or happen only on strange unix 3rd cousins. The issues in PATH include quotes, : in names, leading blanks, interior blanks etc. If the nasty cases are ignored the problem is pretty simple. I have tried to find a statement of the proper form of PATH to no avail.

The problem is not with symlinks but rather with commands that resolve to fullpaths with $PATH. The problem you mention with jconsol in the path is the same and would be fixed if the problem with symlinks were fixed. That said, I think it is generally a bad idea to put the J directory in PATH.

We got carried away with the new box stuff in 601. Just because the few linux systems we worked with had the same boxdraw font we incorrectly assumed it was on all. My guess is that we will revert unix jconsole to +|- and the user will have to do explicitly get boxdraw if the want and have a font.

----- Original Message ----- From: "Raul Miller" <[EMAIL PROTECTED]>
To: "Beta forum" <[email protected]>
Sent: Monday, October 01, 2007 2:18 PM
Subject: Re: [Jbeta] symlink


On 10/1/07, Eric Iverson <[EMAIL PROTECTED]> wrote:
Right now I am stumped. Is there a way in UNIX to know the full path to the program that is running? Is there an easy way (C library call, not use of a
proram like which which can be aliased and otherwise messed with) to find
the full path to a name that is on PATH?

I took a look at this:

First, note that you have this problem even without symlinks.  If I
have the j602 directory in my path, jconsole fails.

Second, note that boxed display defaults to a non-meaningful
behavior for jconsole running on an arbitrary linux box.  To make
this correspond to what is documented at
http://www.jsoftware.com/help/dictionary/dx009.htm
I used the workaround:
  9!:7'+++++++++|-'

To find the directory containing jconsole, ignoring the symlink
issue, I would probably use something like this:

GETENV=: 2!:5
PATH=:<;._1':',GETENV'PATH'
FEXIST=: (1: 1!:4) ::0:"0

mydir=:3 :0
 a0=:0{::ARGV
 p=: PATH
 if.'/'e.a0 do.p=:'.';p end.
 f=:{. (#~ FEXIST) p,&.><'/',a0
 }.;}:<;.1'/',>f
)

To address the symbolic link issue, I would probably use something
like:

dirname=: [: }.@;@}: '/' <;.1@, ]
readlink=: (((('/' ~: [EMAIL PROTECTED]) # '/',[EMAIL PROTECTED]) , ]) 2!:0 @ 
('readlink '
, ])) ::] ^:_

(watch out for line wrap)

I would process f through readlink before finding its directory.

But when I tested this, I was getting intermediate results displayed
to the console when following symbolic links.  I think this is a
j602 beta bug

FYI,

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to