Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!minya!jc From: jc@minya.UUCP (John Chambers) Newsgroups: comp.unix.questions Subject: Re: rsh, rcp and the message "Where are you?" Message-ID: <365@minya.UUCP> Date: Sat, 14-Nov-87 21:00:04 EST Article-I.D.: minya.365 Posted: Sat Nov 14 21:00:04 1987 Date-Received: Sun, 15-Nov-87 20:32:26 EST References: <173@tarski.quintus.UUCP> <9312@mimsy.UUCP> Organization: home Lines: 45 Keywords: SUN OS Summary: I wish I could guarantee it... In article <9312@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: > This (message from biff), by the way, points up the fact that > every program that prints error messages should also print its > own name. If Gregg had seen > % rcp otherhost:file here > biff: Where are you > % > he might at least have had *one* clue as to where to look. This is something I've tried to do since very early in my programming career, after wasting *far* too much time just finding out the source of several bizarre messages that nobody in the computer center could explain. But there is a serious problem with implementing it. Imagine you are writing a function that is to be linked into any of a set of programs (or put into a library). You have written a nice validity test, and are typing an error message that looks like: fprintf(stderr,"%s: ..........\n", Now what do you type? How does a subroutine discover the name of the program that called it? If the function is called "main", the answer is easy: argv[0]. But there is no law saying that argv[0] must be passed as a parameter to every subroutine. When I write programs, I usually include code like: char *progname="?"; ... main(argc,argv) ... progname = argv[0]; ... and then the subroutines that *I* write know where to find the name. The designers of Unix/C, in their wisdom, saw fit to supply us with a global environ[] so we can check the environment without permission from main(), but I have never seen mention of a similar global pointer that leads to the argv[] array. If I've missed something in TFM, I'd love to hear about it. Especially if it is portable to all Unices (or even better, to all Cs). Waiting for flames about how dumb I've been.... -- John Chambers <{adelie,ima,maynard,mit-eddie}!minya!{jc,root}> (617/484-6393)