Date: Sat, 08 Mar 1997 18:54:00 +0000 From: Gareth McCaughan <gjm11@dpmms.cam.ac.uk> To: steve howe <un_x@hotmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: profile/alias Message-ID: <E0w3RFt-0007DD-00@g.pet.cam.ac.uk> In-Reply-To: Your message of "Sat, 08 Mar 1997 04:55:17 PST." <199703081255.EAA25810@hotmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> i posted a problem i find with ~/.profile aliaseson "questions", then > "hackers" and never received any responses. > \ > i have double & triple verified this problem and wonder if i am posting > in the wrong maillist or if i am in serious error in some way ... ? > \ > also, to answer a question of my own - to anyone interesting in > programming - it appears most output/format control is in "ncurses.h", > \ > however - i am still at a loss to find a C function that will tell > me if a key has been pressed, w/o actually waiting for a char. > something like DOSs "kbhit()". > \ > i also cannot find any info on "random()" seeds. "jot(1)" uses > "random()" and generates completely fresh/different random outputs, > as well as DOS random functions i've used, but no matter how i seed > "srandom()" - "random()" always outputs the same output with the > same seed. in my past experience, there is usally a seed that will > always put out a varied sequence (0 or 1 or something ...) The earlier message referred to said: > regarding ~/.profile. any alias as the 1st non-comment line will > show up in a following alias command, but will not function, resulting > in an "alias: not found" error. and secondly, if i use: > export ENV=~/.shinit INSTEAD OF ENV=~/.shinit; export ENV ... > ~/.shinit never gets called on any "sh" startups ... ??? With my ~/.profile containing exactly the following alias zog='echo spong' echo I am the walrus the alias functions exactly as it is supposed to. If you can mail me a copy of your .profile (edit out irrelevancies if you want) I'll see whether I can reproduce the problem. (But I'm running 2.2, not 2.1.5; perhaps there was a problem and it's now been fixed.) You seem to be right about ENV; that's *really* weird. You should submit a problem report using send-pr. For finding whether a key has been hit or not, you could use fcntl to set fd 0 (standard input) to use non-blocking I/O, and then use read() and see whether it returns with error EAGAIN. (If you don't know what some of that means, read the fcntl manpage.) The output of random() is completely determined by the seed you give to srandom(). If you want output that you can't predict in advance, seed srandom() with something unpredictable. Depending on your needs, the time might be good enough (use gettimeofday() to give you a time value with pretty high resolution). For some purposes you might want to investigate the random(4) manpage. -- Gareth McCaughan Dept. of Pure Mathematics & Mathematical Statistics, gjm11@dpmms.cam.ac.uk Cambridge University, England.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E0w3RFt-0007DD-00>