From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b97aa4480eccc494 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!feeder.erje.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: How to get the application path Date: Wed, 1 Aug 2007 23:31:50 -0500 Organization: Jacob's private Usenet server Message-ID: References: <46a456aa$0$25908$426a34cc@news.free.fr> <1185204459.328520.240930@z24g2000prh.googlegroups.com> <46a5e4e1$0$27850$39db0f71@news.song.fi> <0kbqe1zcrk.fsf@hod.lan.m-e-leypold.de> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1186028970 21127 69.95.181.76 (2 Aug 2007 04:29:30 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 2 Aug 2007 04:29:30 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Xref: g2news2.google.com comp.lang.ada:1325 Date: 2007-08-01T23:31:50-05:00 List-Id: "Markus E.L." wrote in message news:o6vec14g46.fsf@hod.lan.m-e-leypold.de... > > > Markus E Leypold 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.