Re: How to get the application path



"Markus E.L." <development-2006-8ecbb5cc8aREMOVETHIS@xxxxxxxxxxxxxxxxxxxxx>
wrote in message news:o6vec14g46.fsf@xxxxxxxxxxxxxxxxxxxxxxxxx

Markus E Leypold
<development-2006-8ecbb5cc8aREMOVETHIS@xxxxxxxxxxxxxxxxxxxxx> writes:

Now, on Unix I'd just put a shell script wrapper in place of the
executable:

Why do you limit this to "Unix"? Any operating system that supports
shells can do the same thing.

Yes+No. In Unix I can just exec the real binary, so I don't have a
shell process waiting until the the binary proper returns. In Windows
the shell process will (AFAI understand it) exist until the
application terminates and AFAIS (worse) it will even have a command
line window open to the absolute irritation of the lay user.

That doesn't have to be the case, although getting rid of it requires yet
another program. (Essentially, you redirect the output to null, although
doing that specifically doesn't work. It took me several days of
trial-and-error to get that to work, and it's not certain to me what I did
specifically that made it work. So I have my doubts that it would work with
another compiler, so I'm not going to share the details [Janus/Ada users can
ask, of course].)

....
I find the Unix way more palatable.

MYPATH="$0"
MYAPP="$(which $MYPATH.bin)" # locate the executable proper

export EXE_PATH="$MYPATH"

exec $MYAPP "$@"

(untested, mind you).

That would even put the full path in argv[0]. The power of shell
script wrappers in Unix is usually underestimated.

Scratch the "in Unix", and I agree.

Could you tell me the equivalent of my script in CMD.exe? (Seriously,
that's a real question: What I got until now I consider kludgy).

Application paths in Windows are supposed to be set in the registry; "Path"
is supposedly obsolete. (Yes, hardly anybody actually follows that
documentation.) As such, you're supposed to put the path into the icon or
(as we do) directly into the script [we have the installer create the
appropriate scripts for the user's machine]. Meaning there is no need for
such fancy scripts.

If I actually had to do this, I'd simply write a Janus/Ada program to do it
(remember that all opens search the path in Janus/Ada, so getting the path
is just a matter of text processing the name). Ada is usually better than
silly scripts anyway. [Although these days I'd put the path into the
registry and use the Claw interface I mentioned last week to retrieve it.]

Moral: trying to make Windows work like Unix necessarily makes tasks harder
than they need to be. (The converse is also true, of course.) Very much like
using Ada as if it is C.

Randy.


.



Relevant Pages

  • Re: Great SWT Program
    ... hours using, or trying to use, Windows and its applications than ... semantically equivalent to the shell. ... I think you mentioned not having access to a Unix system. ...
    (comp.lang.java.programmer)
  • Re: [ Attn: Randy ] Ad-hoc Parsing?
    ... > therefore you loose the primary advantage of writing a script and may ... > matching Unix. ... You use six external programs ('tidy', 'make-make', ... program and not by the shell, ...
    (alt.lang.asm)
  • Re: How do Unix grep, find, sort?
    ... 1996 after starting Windows admin after many years in Unix, ... You could also inline the replace into one script ... Right now it is still much a roll your own world, in Windows ... do go down the road with some script language. ...
    (microsoft.public.windows.server.scripting)
  • Re: How to get the application path
    ... Why do you limit this to "Unix"? ... shell process waiting until the the binary proper returns. ... Could you tell me the equivalent of my script in CMD.exe? ... installation location in the registry and how I ...
    (comp.lang.ada)
  • Re: Lisp/Unix impedance [a programming challenge]
    ... >> I don't think you even have any idea what Unix is. ... nice if using a command shell under Windows didn't feel like working ... with blinders on a command line that's been made deliberately hard to ... An Emacs over a *nix shell is pretty usable at controlling ...
    (comp.lang.lisp)

Loading