HDTenEightyP/NetNews huggingface dataset:
From: yorton@turtle11.rtsg.mot.com (James J. Yorton)
Subject: Re: csh/ksh comparison questions?
Reply-To: yorton@rtsg.mot.com
Organization: Motorola Inc., Cellular Infrastructure Group
Date: Wed, 22 Jul 1992 14:18:57 GMT

In article <1992Jul21.183727.20364@gmuvax2.gmu.edu>, rjackson@gmuvax2.gmu.edu (Richard L Jackson Jr) writes:
|> I did a simple comparison of CSH and KSH.  I am asking this
|> group for solutions to csh feature that ksh appears to lack.
|> I am using ULTRIX 4.1, VAX 8530.
|> 
|> 1) set filec or file completion

In ksh, using vi-style command line editing, try

<ESC>* or <ESC>\ 

where <ESC> is the ESCAPE key.
There is a slight difference.  I'm not a tcsh user, but users tell
me that <ESC>\ is quite similar to tcsh's file name completion.

In ksh, using emacs-style command line editing, try

<ESC><ESC>

|> 
|> 2) concurrent sessions inadvertently use the same history
|>    file.  Appending a pid to the history file at login may help
|>    but there is no logout facility to remove the file.
|> 

How about using a different history file for each tty?
How about something like:

tty=`tty`
export HISTFILE=~/.history_${tty#/dev/}

I suggest you clean up the history files periodically, or you
may have a lot of them laying around.  It's like politics,
some people want it one way, some the other.  Neither is wrong.

|> 3) how does one invoke a .logout script at ksh exit?
|> 

How about putting this at the top of your .profile:

trap '[[ -x ~/.logout ]] && ~/.logout' 0 1 15

which will execute your .logout script (if it's executable)
on the receipt of certain signals.  Do a chmod +x ~/.logout too.
You can then put anything in .logout, including removal of
your history files.

|> Richard Jackson

--------------------------------------+---------------------------------------
James J. Yorton                       | Telephone:  +1 708-632-6695
Motorola Inc., General Systems Sector |
Cellular Infrastructure Group         | internet:  yorton@rtsg.mot.com
1501 - West Shure Drive               | uucp:      ...!uunet!motcid!yorton
Mail Drop:  IL27-3227                 |
Arlington Heights, IL  60004          |
USA                                   |
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.unix.shell
Subject: Re: file name completion for ksh?
Date: 24 Jul 92 17:15:09 GMT
Distribution: na
Organization: NetLabs, Inc.

In article <FRIEDMAN.92Jul24042018@nutrimat.gnu.ai.mit.edu> friedman@gnu.ai.mit.edu (Noah Friedman) writes:
:    Ah yes, features.  What would we do without them?  Probably get more
: work done, instead of endlessly tweaking our environments to no useful end.
: 
:    I probably have the most complicated initialization scripts that anyone
: has ever devised (if you don't believe me, email me and we can arrange to
: compare).  One of these days, when I come to my senses, I'll switch to rc
: and use it vanilla.
: 
:    Features?  You need features like you need poison ivy. 

This is an oversimplification of reality, or at least a misdefinition of
that poor, defenseless word "feature".  The so-called minimalists like to
spout such nonsense:  "Simplicity at any cost!  Make my life easy--I don't
care how hard it makes yours.  Anything new simply MUST be unnecessary,
since we got along without it before."

Horsepucky.

Any proposed feature must be evaluated on its own merits.  A feature
that lets you change the color of a particular widget is just one more
complication to remember--I can understand your antipathy.  But a
feature that makes all your other features twice as powerful is getting
on towards being a necessity.  But it's still a feature.

Are you proposing that we demote the word "feature" to a mere pejorative?
We've already desemanticized far too many words in English.  Such villainy! :-)

Larry Wall
lwall@netlabs.com
From: ian@horse.UUCP ( as in Bunny)
Newsgroups: comp.unix.shell
Subject: Shell Scipt Security
Date: 24 Jul 92 15:06:42 GMT
Organization: Whitehorse Systems Group, Inc


Greetings,

I have produced a lengthy bourne shell script to perform a sequence
of system administration tasks for SCO UNIX users. We are looking for a 
method that we can use to put this shell script on customer sites that
require it but protect it at the same time from being hacked around.

Whether that be a "shell compiler" or some other mechanism I am open
to advice. We need to protect our time and investment in this little project 
and stop it from being copied and stolen.    

If anyone has any ideas please help.

I do not like to ask for anything without giving something in return
so I include a one-liner that I have found useful.
It detects control characters that have mistakenly been placed in
filenames and displays the control character in the form \nnn.
Using this, administrators can inform users in advance why they cannot
retrieve mistyped files.

find / -type f -print | xargs -t ls -qb 2>/dev/null | grep '\\'


---------------------------------------------------------------
Ian Rabbitt                                    
ian@wsg.com                                    
Whitehorse Systems Group, INC                   
534 Main St. South Portland ME USA 04106
_______________________________________________________________
Newsgroups: comp.unix.shell
From: peer@ccrma.stanford.edu (Peer Landa)
Subject: Sort problem . .
Organization: DSO, Stanford University
Date: Mon, 27 Jul 92 12:34:15 GMT

 
I'm trying to list & sort all my processes by memory use:
alias  pss  ' ps uax | sort -nr +3'
It works fine except for that the "title line" also gets sorted and therefore  
appears at the bottom . . any idea to avoid this ?

-- peer

Xref: sparky comp.unix.shell:3075 comp.lang.perl:4842
From: brendan@cs.widener.edu (Brendan Kehoe)
Newsgroups: comp.unix.shell,comp.lang.perl
Subject: Re: How to compile a shell script?
Date: 21 Jul 92 12:40:27 GMT
Article-I.D.: betty.14h0jrINNvd
Organization: Widener University Computer Science Dept, Chester PA
NNTP-Posting-Host: betty.cs.widener.edu

chung@cis.ohio-state.edu wrote:
>	Is there any way I can compile a shell script file so that it can
>run faster?

Someday someone will write sh2perl.  (Note you'd probably only really
win on things that were more procedurally heavy than exec'ing a lot of
different shell commands for various things.)

-- 
Brendan Kehoe, Sun Network Manager                      brendan@cs.widener.edu
Widener University                                                 Chester, PA
                                              At Bennigan's, EVERYONE gets it!
Newsgroups: comp.unix.shell
From: esh@lithium.tekbspa.com (Edward S. Hirgelt)
Subject: Re: Sort problem . .
Organization: Direct Interfaces Corporation @ Teknekron
	<1992Jul31.000822.13317@convex.com>
Date: Fri, 31 Jul 1992 18:10:36 GMT


On 31 Jul 92 00:08:22 GMT,
tchrist@convex.COM (Tom Christiansen) said:

Tom> Boyd is dead right here.  I am constantly incensed by massively
Tom> UNIX-ignorant programmers who inflict brain-damaged software on 
Tom> the rest of us who actually try to use it.  You know, the ones who
Tom> simply don't have any concept of how filters should work, what 
Tom> stderr is for, how to parse options, what the exit status 
Tom> should be used for, or who only supply an interactive interface.

Tom> Expected output should go out to stdout.  Exceptional output related
Tom> to diagnostics or other error messages should go out stderr.  

This is definitely correct, but let me offer an explanation as to why
this is a `good thing'. Actually, it's simple. I want to route
`standard' output to a filter or to another file put keep errors routed
to my terminal so I can see what is going on. Alternatives, I may log
the errors from a command sequence for examination later.

There are a couple of concepts that help make Unix flexible and
useful. One is the ability to compose functions (pipes). Associated with
that is the split of information into stdout and stderr. This allows the
construction of filters and the creation of log files easily.

Exit status is a pet peeve of mine. There are large numbers of programs
in common use that do NOT set the error status at all. I suspect that
the code just drops through main or uses a return without a value. I
remember working with the Whitesmith's C compiler many years ago. It did
set its exit status consistently. Unfortunately it was 180 degrees
opposed to the standard in Unix. It used 1 for success and 0 for
failure. It made for some very interesting makefiles. We took the
expedient way out -- ignored the exit status from the compiler. We never
really knew if the make succeeded or not.

It really isn't a matter of flexibility but rather one of consistency.

Thanks to Boyd and Tom to pointing this out.

Ed
--
Ed Hirgelt			esh@tss.com
Direct Interfaces Corporation
San Jose, Ca.
Newsgroups: comp.unix.shell
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: Sort problem . .
Originator: tchrist@pixel.convex.com
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: CONVEX Realtime Development, Colorado Springs, CO
Date: Wed, 29 Jul 1992 19:16:14 GMT
X-Disclaimer: This message was written by a user at CONVEX Computer
              Corp. The opinions expressed are those of the user and
              not necessarily those of CONVEX.

From the keyboard of messina@netcom.com (Tony Porczyk):
:Seems to me like the simplest solution would be to change line 725 in ps.c
:(maybe somewhere else in your source) from:
:
:printf("%s COMMAND\n", hdr);
:
:to:
:
:fprintf(stderr, "%s COMMAND\n", hdr);
:
:and recompile it.

Take off, hoser.  :-)

*Never* hack source when a wrapper will do. And some (most?) people 
don't even have source.

--tom
-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist
    If you have ever seen the grim word "login:" on a screen, your mind
    is now a wholly-owned subsidiary of The Death Star.
                John Woods in <14105@ksr.com> of comp.unix.bsd
Newsgroups: comp.unix.shell
From: snk@fork.bae.bellcore.com (Samuel N Kamens)
Subject: Re: setting variable from script to current environment??
Reply-To: snk@bae.bellcore.com
Organization: Bell Communications Research
Date: Thu, 23 Jul 92 19:19:28 GMT

In article <1992Jul22.014834.1384@jpradley.jpr.com>, jpr@jpradley.jpr.com (Jean-Pierre Radley) writes:
> In article <1992Jul21.070212.16485@gbrmpa.gov.au> wayne@gbrmpa.gov.au (Wayne Amisano) writes:
> 
> If you "source script" (csh, tcsh), or ". script" (sh, ksh), then yes, you can
> set variables that way.


One thing to be careful of when you source shells -- if those shells
have an "exit" in them, that will cause the *PARENT* process to exit.

I can't count how many times I have sourced a file that did an exit
and watched my xterm disappear..... :-(

Sam 

-- 
Sam Kamens					Bell Communications Research
snk@bae.bellcore.com				Phone: (908) 699-7509
444 Hoes Lane  Room RRC 1D-210
Piscataway, NJ 08854
Newsgroups: comp.unix.shell
From: adh@cbnewsi.cb.att.com (andrew.d.hay)
Newsgroups: comp.unix.shell
Subject: Re: check for time stamp in ksh
Date: 30 Jul 92 12:12:40 GMT
Distribution: na
Organization: AT&T

In article <1992Jul24.192127.15710@alw.nih.gov> chintam@alw.nih.gov (Niranjan Chintam) writes:
"Is there a simple script which can check if a particular file has been updated on a give day.
"
"I have written the following script is there any other way to do the same.
[]

read up on find(1), esp. the -[amc]time options.

-- 
		+--------------------------------------------------------------+
Andrew Hay	|         I want to lie, shipwrecked and comatose -	       |
a_d_hay@att.com	|              Drinking fresh mango juice...		       |
		+--------------------------------------------------------------+
Newsgroups: comp.unix.shell
From: yeates@rtsg.mot.com (Tony J Yeates)
Subject: Re: tcsh in the future - what should it be like?
Keywords: tcsh
Organization: Motorola Inc., Cellular Infrastructure Group
Distribution: comp.unix.shell
Date: Thu, 23 Jul 1992 18:59:38 GMT

sjane@bmers248.bnr.ca (sjs) writes:

>In article <yeates.711122638@beryl17> yeates@rtsg.mot.com (Tony J Yeates) writes:
  I have only one suggestion
>>for improvement in this area - command line completion using the command history list
>>(as well as the "by filename completion feature" - which is great), as 4DOS has.
>>e.g. type "vi " then hit a "choosen key" (up arrow is already taken) to scroll thro'
>>(only) the previous vi commands.

>This function is already available.  It is called history-search-backward.
>You can bind it to a function key as I have bound it to F7  on my Sun:

>bindkey ^[[230z history-search-backward

>History-search-forward is also available in case you go too far too fast
>with history-search-backward.

Somebody else suggested using:-
bindkey "^[[A" history-search-backward

... which worked on my Sun.  Excellent, tcsh is now complete (almost!).

>====================================================================
>I'd also like the file completion to select one of completions if there
>are many instead of just beeping at me.  And then if I hit the tab key
>again, it should select another possible completion.. just like the PC.

I would second this suggestion.  Perhaps something like the way
<TAB> and <space> can be used to select groups (G) when using nn.

Newsgroups: comp.unix.shell
From: boyd@prl.dec.com (Boyd Roberts)
Subject: Re: Sort problem . .
Organization: Digital Equipment Corporation - Paris Research Laboratory
Date: Mon, 27 Jul 1992 13:59:02 GMT

In article <1992Jul27.123415.977@leland.Stanford.EDU>, peer@ccrma.stanford.edu (Peer Landa) writes:
> alias  pss  ' ps uax | sort -nr +3'
> It works fine except for that the "title line" also gets sorted...

    ps uax | sed 1d | sort -nr +3


Boyd Roberts			boyd@prl.dec.com

``When the going gets wierd, the weird turn pro...''
 
Newsgroups: comp.unix.shell
From: dylan@ibmpcug.co.uk (Matthew Farwell)
Subject: Re: file locking in shell scripts
Organization: The IBM PC User Group, UK.
Date: Fri, 24 Jul 1992 14:21:56 GMT

In article <FRIEDMAN.92Jul24055302@nutrimat.gnu.ai.mit.edu> friedman@gnu.ai.mit.edu (Noah Friedman) writes:
>In article <1992Jul23.124327.20843@cv.ruu.nl> rvloon@cv.ruu.nl (Ronald van Loon) writes:
>>Somewhere on our system is a log-file. This logfile is used to gather
>>statistical information. However, it is possible that people write to the file
>>at the same time, thus resulting in either the merge of the input-streams or
>>total garbage in the file.
>>
>>How can I - within a shell script - lock the file exclusive for writing ? If
>>that's not possible, what do I need to use to do so from C, for example ?
>   If you can design the locking protocol yourself, and make sure that
>every interface people will use to write the log file will follow that
>protocol, you can specify when a file is locked by creating a separate
>lockfile.  Other programs seeing this file will know someone else has a
>lock on the log file (many mail programs use this "advisory" locking
>method).  You can easily create a lock file in a C program using
>
>            open (lockfile_path, O_CREAT|O_EXCL|..., mode);
>
>(appropriate error checking omitted, since that part is obvious).  This
>means that open will only create the file if it does not already exist.
>This is an atomic operation, so you shouldn't have to worry about any race
>conditions (locally, anyway.. I don't know if anything is guaranteed over
>NFS, including other locking methods!)

Nothing is guaranteed over NFS, apart from link(2)[*].  There was a
thread about a week ago which covered this exact subject.  You could use
ln(1) for this purpose, but Sys V has broken ln(1), so you have to write
your own little locking program, or use the lock program provided below
(which is 'newslock' from the c-news distribution.) You have to have
something like this in your script:

LOCKFILE=LOCKFILE
TMP=L.$$

echo $$ > $TMP
if newslock $TMP $LOCKFILE
then
	# you have the lock
else
	# you dont have the lock
fi

And this is the program:

/*
 * newslock - simple, unbroken version of ln(1) for shell-program locking
 *
 * (System V has broken ln(1) itself.)
 */
#include <stdio.h>

main(argc, argv)
int argc;
char *argv[];
{
	if (argc != 3) {
		fprintf(stderr, "Usage: %s tempname lockname\n", argv[0]);
		exit(2);
	}

	if (link(argv[1], argv[2]) < 0)
		exit(1);
	else
		exit(0);
	/* NOTREACHED */
}

Can someone please add this to the FAQ?

Dylan.
------
[*] With NFS, the locking is atomic, but you can find yourself with
stale locks hanging around, if you're unlucky.
-- 
It is no coincidence that in no known language does the phrase 'As
pretty as an Airport' appear -- Douglas Adams
Newsgroups: comp.unix.shell
From: shemminga@cix.compulink.co.uk (Stuart Hemming)
Subject: TCSH
Reply-To: shemminga@cix.compulink.co.uk
Date: Thu, 30 Jul 1992 08:18:00 +0000


I don't wish to consume acres of bandwidth, so would some kind soul
like to mail me with a description of what tcsh is, where it comes
from, if I can get it and if I need it?

BTW, I'm running inactive Unix 3.2 on a '486 box.

TIA,

Stuart
--
These opinions are mine -- let's face it who'd want them

Send me mail -- No reasons, just send it.

stuart@cix.compulink.co.uk            Tel +44 778 426444
[Stuart Hemming]
Newsgroups: comp.unix.shell
From: Harald.Eikrem@delab.sintef.no
Subject: Re: Sort problem . .
Organization: SINTEF DELAB, Trondheim, Norway.
	<1992Jul27.140110.846@news.eng.convex.com>
	<1992Jul28.095415.4640@prl.dec.com>
	<1992Jul28.102938.12375@news.eng.convex.com>
Date: 28 Jul 92 22:31:13

! This does seem to work:
! 
! 	ps axu | (read line; echo "$line"; sort +3rn) 

Yeah, nice for {,k,z,ba}sh.  Why not simply

        ps aux | ( line; sort -rn +3 )

  ~~h
From: smr@iti.org (Stephen Riehm)
Newsgroups: comp.unix.shell
Subject: Re: setting variable from script to current environment??
Date: 22 Jul 92 14:33:09 GMT

wayne@gbrmpa.gov.au (Wayne Amisano) writes:

>I am trying to write a script to set an environment variable in
>my tcsh environment.  I could use an alias to do it, but would
>much rather do it from a script.  What i need to do is, run a
>script to change the value of one environment variable, but
>every time i do this, it changes the variable in the spawned
>process, but it then disappears when it dies.

if it is not possible to use an alias, ( because it is too complex or
whatever ), try the following:

create your shell script
create an alias along the lines of:
	alias <alias> 'source <script>'

where <alias> and <script> are substituted with reasonable values.
This will solve your problem, because the current process runs the
script, and not a subshell!

>-- 
>Wayne Amisano (VK4KT)     _-_|\\    E-Mail - wayne@gbrmpa.gov.au
>Great Barrier Reef       /     \\   Phone  - +61 77 81 8861 (GMT+1000)
>Marine Park Authority.   \_.-._/    Fax    - +61 77 72 6093
>Our's to use Wisely!          v     Mail   - GPO Box 1379, Townsville QLD 4810

Finally one of those character piccies of Aus. Wish I had one! ;-)

catchya

-----------------------------------------------------------------
Stephen Riehm				   smr@pki-nbg.philips.de
not in any way talking on behalf of:
Philips Kommunikations Industrie	  Phone: +49 911 526 2975
8500 Nuremberg, Germany			    Fax: +49 911 526 2095
I come from the land down under, where women glow and men chunder
From: chip@eniac.seas.upenn.edu (Charles H. Buchholtz)
Newsgroups: comp.unix.shell
Subject: Where does the sugar go? (was Re: Sort problem )
Date: 31 Jul 92 03:30:28 GMT
Organization: University of Pennsylvania

tchrist@convex.COM (Tom Christiansen) writes:
>
>Expected output should go out to stdout.  Exceptional output related
>to diagnostics or other error messages should go out stderr.  

I agree, but I often wonder what to do with the output "sugar", such
as prompts or headers, which are not well suited for filtering.  It's
nice when someone is looking at the output, but takes extra effort to
remove when piped into a filter, eg

	finger | tail +2l | [...]
	ps | (read header; echo "$header"; [...])

So, folks, what's the verdict?  Output goes to stdout, preferably
arranged in lines and fields for easy filtering.  Error messages and
diagnostics (abnormal stuff) goes to stderr.  Where should the sugar
go?  stdout?  /dev/tty?  /dev/null?  >&3?


Charles H. Buchholtz       Systems Programmer     chip@seas.upenn.edu
	      School of Engineering and Applied Science
		      University of Pennsylvania
Newsgroups: comp.unix.shell
From: gfong@bellahs.com (Gary Fong RD)
Subject: Re: file name completion for ksh?
Organization: Bell Atlantic Healthcare Systems
Distribution: na
Date: Tue, 28 Jul 1992 23:56:17 GMT

In article <1992Jul20.143443.16536@rtsg.mot.com> yorton@rtsg.mot.com writes:
>In article <1992Jul16.222941.3939@sco.COM>, zackx@sco.COM (Zack Xu) writes:
>|> Does some enhanced version of ksh have the "interactive command,
>|> file name and user name completion" feature of tcsh?  I am
>|> currently still using tcsh because of this feature I found
>|> very useful.  For interactive use, can someone run a comparison
>|> of tcsh and ksh?  and try to convince/convert me to be a ksh
>|> user?
>|> 
>
>Not sure what you mean by the "enhanced" version of ksh, but the
>one I'm referring to is ksh88g from the Toolchest.
>
>For filename completion, with vi-style command line editing,
>try
>	<ESC>* or <ESC>\  
>
>For emacs style command line editing try
>	<ESC><ESC>

I believe what Zack meant is that in csh, if filec is set on, then hitting
say k<ESC> will show all the commands that start with k.  In ksh, I don't
know how this works.  Hitting k<ESC><ESC> will only give me what starts with
k in the current directory.

>Never heard of "user name completion", but if you're referring
>to ~ expansion of the home directory, then yes ksh does have it too.

Again, I believe what Zack meant is that in csh, you can type ~g<ESC> and it
will be completed with the login user name that begins with g.

With both of these completion mechanisms, a list of selections for ambiguous
situations are printed to the screen - just like in ksh when looking for a
file.

gfong@bellahs.com
Bell Atlantic Healthcare Systems
*DISCLAIMER: Everything I say, I said!
Newsgroups: comp.unix.shell
From: lamy@sobeco.com (Jean-Francois Lamy)
Subject: Re: sh equivalent of csh's `source` wanted
Organization: Sobeco Ernst & Young
Date: Fri, 31 Jul 92 13:54:11 GMT
Keywords: help

In <ericw.712530389@hobbes> ericw@hobbes.amd.com (Eric Wedaa) writes:

>HELP!!!  One of my users needs the Bourne Shell equivalent of csh's 
>`source` command.  I don't think this is possible?  Any suggestions?

The command is spelled ".", as in

. filename

Jean-Francois Lamy                                        |   lamy@sobeco.com
Computer Networks and Systems				  |   lamy@sobeco.ca
Sobeco Ernst & Young, Montreal, Canada H2Z 1Y7            |   uunet!sobeco!lamy

Newsgroups: comp.unix.shell
From: mjb@netcom.com (Martin Brown)
Subject: Re: Aho, Kernighan & Weinberger paper on awk
Date: Mon, 27 Jul 92 16:11:43 GMT
Organization: Netcom - Online Communication Services (408 241-9760 guest)
Distribution: na

Just in case you somehow missed it:

     "The AWK Programming Language"

      by: Aho, Kernighan, and Weinberger

      Addison-Wesley Publishing Co.

      isbn: 0-201-07981-X

-- 

                                   - mjb -

                                mjb@netcom.com

From: kevinl@tisdec.tis.tandy.com
Date: 30 Jul 92 16:19 CDT
Newsgroups: comp.unix.shell
Subject: Re: Orphaned Response
Message-ID: <28300001@tisdec.tis.tandy.com>
Nf-ID: #R:cbnewsi.cb.att.com:19391:tisdec.tis.tandy.com:28300001:000:178
Nf-From: tisdec.tis.tandy.com!kevinl    Jul 30 16:19:00 1992


	I just use something like the following:

export PS1='$PWD'

in my .profile.  This will display a sort of DOS style prompt,
letting the present working directory be the prompt.