HDTenEightyP/NetNews huggingface dataset:
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Shell Scripts vs. C programs
Organization: Computer Science, University of Melbourne, Australia
Date: Wed, 2 Sep 1992 14:42:42 GMT

Kim Holburn <kim@csc.canberra.edu.au> writes:

>In article <1992Sep1.044434.7193@news.acns.nwu.edu> John Navarra,
>navarra@casbah.acns.nwu.edu writes:
>>>>I've heard that if at all possible, code a program as a shell script
>>>>rather than coding it in C.  Can someone explain the rationale behind
>>>>this philosophy?
>>>
>>>	BZZZ - shell scripts are non-portable
>>>
>>	Huh? Why are shell scripts non-portable? Unless you are using
>>a non-standard shell, shell scripts are HIGHLY portable! Even if you
>>aren't using a non-standard shell, say [ba|k|z|]sh, it is highly
>>portable.
>>For one, most [ba|k|z]sh scripts will run in sh and vice versa. And, if
>>you need to, you can always get shell X and compile it on your machine.
>>This is *usually* easier than rewriting C-code to accomodate your OS.

>Not true. Having just had to port a set of programs that included C
>programs and bourne-shell scripts from sunOS 4.1.x to sequent Dynix/ptx
>(system V release 3.2). I can say that while the C took a day to port,
>the shell scripts have taken over a week with another week maybe 2
>likely. The C, because of conditional compilation is still a uniform set
>of source. The scripts have diverged fairly rapidly and are not
>interchangeable at all now. 

Huh? What happened to conditional execution?
eg.
	if [ `arch` = "sgi" ]; then
		# SGI-specific code
	endif

Another simple way of making shell scripts portable is to use header files,
just like in C.

	. /usr/local/lib/standard_defines.sh    # standard variable definitions

	if [ $SGI ]; then	
		# SGI-specific code 
	fi

There is no justification for allowing the maintenance problem that will
result from having multiple differing copies of each script for each machine.

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
From: ngervae@next.com (Nik Gervae)
Newsgroups: comp.unix.shell
Subject: Re: recursive mkdir
Date: 25 Aug 92 20:59:13 GMT

In article <1992Aug18.130437.26357@prl.dec.com> boyd@prl.dec.com (Boyd Roberts)  
writes:
> In article <1992Aug18.033048.7574@physiol.su.OZ.AU>, john@physiol.su.OZ.AU  
(John Mackin) writes:
> > 
> > I append to this message a _portable_ recursive mkdir written in plain
> > vanilla sh.  As an added bonus, it even has error checking!  Gosh!
> > 
> 
> Funny things is that a (simplified) version of this script was published
> with the original UNIX paper(s) indicating one of the drawbacks of being
> able to do exactly that.

What about "mkdirs"? Is that not a standard command?

--
Nik Gervae
Software Publications, NeXT Computer, Inc.
ngervae@next.com
[[[[NXDisclaimer alloc] init] disclaim] free];
Xref: sparky comp.unix.shell:3735 comp.unix.questions:10611
From: donn@carson.u.washington.edu (Donn Cave)
Newsgroups: comp.unix.shell,comp.unix.questions
Subject: Re: Shell Scripts vs. C programs
Keywords: shell script, C
Date: 1 Sep 92 17:36:04 GMT
Article-I.D.: u.1992Sep1.173604.15563
Organization: University of Washington

root@steiny.com (Admin) writes:

|navarra@casbah.acns.nwu.edu (John Navarra) writes:

|>In article <119@steiny.com> steiny@steiny.com (Don Steiny) writes:
|>|nurban@tjhsst writes:
|>|
|>|
|>|>I've heard that if at all possible, code a program as a shell script
|>|>rather than coding it in C.  Can someone explain the rationale behind
|>|>this philosophy?
|>|
|>|	BZZZ - shell scripts are non-portable
|>|
|>	Huh? Why are shell scripts non-portable? Unless you are using
|>a non-standard shell, shell scripts are HIGHLY portable! 

| 	The shell may be, but the utilities that the shell calls in order
| to operate are not, thus, shell scripts are non-portable.

Actually, the shell may be about as bad as the utilities, if by utilities
you mean things like sed and awk.  These will be slightly different, but
the discrepancies between System V and BSD shells can be quite a pain,
especially when you have to clean up after someone who didn't know about
them.  C is very portable, by comparison.

| 	If you accidently misspell a variable name, then the shell simply
| takes it as a declaration.     In the 14 years I have been working 
| professionally with UNIX I have witnessed numerous attempts to write
| substantial applications in the shell and they have all failed.

I have wondered if it would be possible to develop a reasonably usable shell
language that would have "software engineering" features for writing large
systems.  For me, that would mean some level of typing, structured types,
functional scoping, and some way to deal with code in separate modules,
but I'm sure there's more to it if one were to consult some standard texts
on this issue.  Would be nice to be able to create somewhat complex data
types, e.g., trees, and store "pointers" to functions, but not necessarily
the way C does it, maybe more like Lisp.  It would of course need to be
able to run fairly efficient code.  Seriously, it would also want to have
a little style, rather than being a grab-bag amalgam of every known
programming language, which can impair readability.  (Tom, I'm not hostile
to perl, so don't be bashful about saying perl has all of these things and
more, but jeez it looks messy.)  My rather simplistic attitude is that good
code can be fiddled with in one place, without unanticipatable side effects
in other places.

If there's any advantage to such a thing, over C, it would be the sort of
padded environment that allows programs to be written fairly quickly without
worrying about dereferencing null pointers and things like that.  Ideally,
it would also be possible to convert straight to C without much re-design,
so it could be used for prototyping.

	Donn Cave, University Computing Services, University of Washington
	donn@cac.washington.edu
From: sasegb@toklas.unx.sas.com (Elizabeth Brownrigg)
Newsgroups: comp.unix.shell
Subject: Re: Sed with shell variables
Date: 26 Aug 92 14:34:31 GMT
Organization: SAS Institute Inc.
Originator: sasegb@toklas.unx.sas.com


In article <2701@nlsun1.oracle.nl>, rgasch@nl.oracle.com (Robert Gasch) writes:
|> Using sed to edit strings is usually a nice and practical
|> method of doing so. I you want to change a pattern you usually
|> say:
|>      echo $something|sed 's/pattern1/pattern2/'
|> 
|> The problem I ran into is that I can't get shell variables to
|> work as arguments. When I type
|>      echo $something|sed 's/$this_pattern_var/$that_pattern_var/'
|> 
|> sed throws up on me. I've tried various combinations of quotation
|> marks without success. Is there an easy way of doing this??
|> 
|> Thanks a lot
|> ---> Rob


 Here's a script I wrote using sed and shell variables to globally
search and replace strings in all the files in a subdirectory:


echo "Enter the search string.  Precede regular expressions with
a double backslash."

read firststring

echo "Enter the replacement string.  Precede regular expressions
with a double backslash."

read secondstring

for file in *

do
    echo 'Starting file '$file

# Use the sed editor to search and replace firststring with
# secondstring in each file in the subdirectory.  Write the corrected 
# file to file.sed.
    sed "s/$firststring/$secondstring/g" $file >$file.sed

    rm $file
    mv $file.sed $file

    echo 'Ending file '$file

done



- Elizabeth
Newsgroups: comp.unix.shell
From: hung@octel.com (Hung Le)
Subject: Re: cant delete file!
Keywords: funny filenames!
Organization: Octel Communications Inc., Milpitas Ca.
Date: Wed, 2 Sep 1992 00:49:26 GMT

In article <BtLrxr.77G@acsu.buffalo.edu> vidya-v@acsu.buffalo.edu (vidyaranya) writes:
>
>A file has been created in my directory accidentally,
>possibly while reading disk on a SparcStation IPC. I am unable
>to remove it. The file name appears as:
>
>-rw-r--r--  1 vidya-v         0 Aug 24 12:02 A??LN???N???-@??-
>
>How do I delet it? I tried escaping the '?' and '@' as follows:
>
>daisy [~] 43: rm A\?\?LN\?\?\?N\?\?\?-\@\?\?-

	You could use the command:

	/bin/rm -i A*

	then answer 'y' for the appropriate file that you want to delete.
	Good luck.

	Cheers,
Xref: sparky comp.unix.shell:3746 comp.unix.questions:10623
From: rayj@Celestial.COM (Ray Jones)
Newsgroups: comp.unix.shell,comp.unix.questions
Subject: Re: Shell Scripts vs. C programs
Keywords: shell script, C
Date: 1 Sep 92 18:31:07 GMT
Organization: Celestial Software, Mercer Island, WA

In <la5b90INN6v8@almaak.usc.edu> ajayshah@almaak.usc.edu (Ajay Shah) writes:

>nurban@tjhsst () writes:

>>I've heard that if at all possible, code a program as a shell script
>>rather than coding it in C.  Can someone explain the rationale behind
>>this philosophy?

>It's not so much a rule as a additional design alternative unique to
>the Unix environment.

>Shell scripts are frequently easy to write (esp. using sed/awk glue).
>They help in quickly getting a small system running.  They are
>tremendously powerful in automating mundane tasks.  In situations
>where you know you will throw away the code in a few weeks, the
>shell script approach is almost always better.

>Generally shellscripts are slower than a hand-tuned C program.
>When the script gets too large, it's easier to debug C instead
>of sh/sed/awk.  There are better debugging tools for C (a
>weakness of the sh/sed/awk paradigm which sounds fixable to me).

I agree with most of what you said, however, in some cases a shellscript
is actualy faster (not often, but sometimes).  They are much smaller in
terms of storage space.  As to debugging tools, try "sh -x scriptname".
This will show you every command as it execuites WITH THE SHELL
SUBSTITUIONS as they occure.  If this produces too much information, put
set -x
lines of code under question
set +x  # to turn off debuggingh


-- 
Onager Systems			 Ray A. Jones
18710 NE 59th Ct.		UUCP .....uunet!camco!onager!ray
# 2053       			...ray@onager.Celestial.COM
Redmond, WA 98052               206-885-3568 
Newsgroups: comp.unix.shell
From: ant@palm21 (Tony Jones)
Subject: Re: Help with directories!
Followup-To: /dev/null
Organization: Cray Research Inc, Eagan, MN
X-Newsreader: Tin 1.1 PL5
Date: 28 Aug 92 16:20:12 CDT

: > Oddly enough, the Domain Name System doesn't know "cray.csc.ncsu.edu".
: > Now why doesn't that surprise me?
: 
: Oddly enough, the Domain Name System doesn't know "john@physiol.su.OZ.AU".
: Is there some special meaning in this?  What the hell is your problem?

The domain system does know 'physiol.su.OZ.AU', not every host needs an
A(ddress) record (usually when there not directly connected to the Internet)
In this case it has a MX (mail exchange) record.

There is nothing in either address or MX info for 'cray.csc.ncsu.edu'

[just thought it was worth pointing out, i'm not justifing the original
posting, which is just ludicrous beyond words - anyone got a dictionary ?]


Tony

Followup-To: /dev/null (please !!)

--
Tony Jones (ant@cray.com, ..!uunet!cray!ant)
ComMon Compiler System
Cray Research Inc, 655F Lone Oak Road, Eagan, MN 55121
From: morten@oase.kemi.aau.dk (Morten Kjeldgaard)
Newsgroups: comp.unix.shell
Subject: Interactive csh: what is the comment char?
Date: 1 Sep 92 10:02:35 GMT
Organization: Aarhus University, Denmark

What is the comment character in an interactive csh? When I go

	% # comment

is says

	#: Command not found

???

/Morten


--
Morten Kjeldgaard  ~ morten@oase.kemi.aau.dk ~ mok@kemi.aau.dk
Biostructural Chemistry, Department of Chemistry, Aarhus University
Langelandsgade 140, DK-8000 Aarhus C, Denmark
Phone: +45 86 12 46 33 ~ +45 86 20 27 11 x6518 ~ Fax: +45 86 19 61 99
Newsgroups: comp.unix.shell,comp.unix.questions
From: Kim Holburn <kim@csc.canberra.edu.au>
Subject: Re: Shell Scripts vs. C programs
X-Xxmessage-Id: <A6C95F2ACB0105C3@taiji.canberra.edu.au>
X-Xxdate: Tue, 1 Sep 92 01:55:54 GMT
Organization: University of Canberra
X-Useragent: Nuntius v1.1.1d9
Date: Tue, 1 Sep 92 07:39:56 GMT

In article <1992Sep1.044434.7193@news.acns.nwu.edu> John Navarra,
navarra@casbah.acns.nwu.edu writes:
>>>I've heard that if at all possible, code a program as a shell script
>>>rather than coding it in C.  Can someone explain the rationale behind
>>>this philosophy?
>>
>>	BZZZ - shell scripts are non-portable
>>
>	Huh? Why are shell scripts non-portable? Unless you are using
>a non-standard shell, shell scripts are HIGHLY portable! Even if you
>aren't using a non-standard shell, say [ba|k|z|]sh, it is highly
portable.
>For one, most [ba|k|z]sh scripts will run in sh and vice versa. And, if
you 
>need to, you can always get shell X and compile it on your machine. This
is
>*usually* easier than rewriting C-code to accomodate your OS. 
>

Not true. Having just had to port a set of programs that included C
programs and bourne-shell scripts from sunOS 4.1.x to sequent Dynix/ptx
(system V release 3.2). I can say that while the C took a day to port,
the shell scripts have taken over a week with another week maybe 2
likely. The C, because of conditional compilation is still a uniform set
of source. The scripts have diverged fairly rapidly and are not
interchangeable at all now. 

+----------------------------+-----------------------------------------+
|   Kim Holburn              |   Internet : kim@csc.canberra.edu.au    |
|   Computer Services Centre |                                         |
|   University of Canberra   |   Phone    : (06)201 2203, (06)201 2401 |
|   PO Box 1 Belconnen       |                                         |
|   ACT  Australia           |   Fax      : (06)201 5074               |
+----------------------------+-----------------------------------------+
|     born again and again and again and again and again buddhist      |
|                    well... in a previous life anyway  :-)            |
+----------------------------------------------------------------------+
Newsgroups: comp.unix.shell,comp.unix.questions
From: agc@bmdhh298.bnr.ca (Alan Carter)
Subject: Re: Need help from a make guru
Organization: BNR-Europe-Limited, Maidenhead, England
Date: Thu, 03 Sep 1992 10:55:54 GMT

In article <Btytp9.BKs@news.larc.nasa.gov>, alan@hal.larc.nasa.gov (alan dare) writes:
|> 
|> In our application we wanted to keep the object and source separate from 
|> each other in a directory structure as shown below:
|> 
|> 			<topdir>
|> 			   |
|> 			  / \
|> 	   	obj  src
|> 
|> My current makefile does this quite well. It also doesn't require a separate
|> condition for each source. Problem: Several users add modules to a 
|> executive then compile it. It would would be nice if they didn't have to
|> modify the makefile. The makefile would just compile any source file in the
|> current directory. I have taken several stabs at it, but I am not having
|> any luck. All I need for it to work is a variable containing a list of
|> the source and a variable containing the objects with the directory path 
|> "../obj/" prefixed to it.  Below is a makefile that would compile all *.c and
|> create a a.out file. However, I can't get make to execute the shell command
|> correctly on the OBJECTS line correctly (the line is a valid shell command).
|> 
|> OBJDIR = ../obj
|> 
|> SOURCE=*.c
|> OBJECTS=`for i in \`ls *.c |sed 's/\.c/.o/g'\`; do echo "../obj/$i"; done`
|> $(OBJDIR)/a.out:  $(OBJECTS) 
|> 	cc -o $@ $(OBJECTS) 
|> 
|> $(OBJECTS) : $SOURCE
|> 	cc -c $(OPT)  $(@F:o=c) -o $@ 
|> 
|> Can anybody tell me how I can get the OBJECT variable set correctly?

Your problem is that you are trying to nest the stuff in `` command line
substitution braces. This is not allowed. Do it in two steps:

TEMP=`ls *.c |sed 's/\.c/.o/g'\`
OBJECTS=`for i in $TEMP; do echo "../obj/$i"; done`

   Alan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Maidenhead itself is too snobby to be pleasant. It is the haunt of the
   river swell and his overdressed female companion. It is the town of showy
   hotels, patronized chiefly by dudes and ballet girls. 

   Three Men In A Boat, Jerome K. Jerome, 1889
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: friedman@gnu.ai.mit.edu (Noah Friedman)
Newsgroups: comp.unix.shell
Subject: Re: shell to "C" compilers, any out there??
Date: 2 Sep 92 09:01:51 GMT
Organization: Free Software Foundation, 675 Mass Ave. Cambridge, MA 02139
In-reply-to: rod@philips.oz.au's message of 2 Sep 92 01:08:25 GMT

In article <1992Sep2.010825.2610@philips.oz.au> rod@philips.oz.au (Rod Roberts) writes:
>I have been wondering if there is such a thing as a shell script compiler
>either commercial or pd/freeware. I have heard of such beasts but havn't
>seen one. I imagine it would take a shell script is input and generate a
>"C" source file. Can anyone point me in the right direction. ThanX in
>advance.

   I'd suggest using Archie (I don't know of any shell-to-C compilers out
there off-hand).  I mainly wanted to mention that a shell to C compiler is
not likely to buy you much, since the most expensive parts of most shell
scripts are the parts that exec external programs.  That's going to be slow
whether you do it in shell script or using `system' from a C program.
From: kan9691@bcstec.ca.boeing.com (Ken Niedermeyer)
Newsgroups: comp.unix.shell
Subject: Re: Keeping mods AND owners of copied files
Date: 26 Aug 92 16:41:06 GMT
Organization: Drawing Data Management Systems
X-Newsreader: Tin 1.1 PL4

Thanks to everyone who emailed solutions AND examples!!!
Here is what I found out:

cpio will copy directory hierarchies preserving mods and owners:

        create the directory to be copied to (newdirectoryname)	
	cd to the directory to be copied from
        find . -depth -print | cpio -pdlm newdirectoryname

tar will copy directory hierarchies (without going to tape first)
    preserving mods and owners:

	create the directory to be copied to (newdirectoryname)
	cd to the directory to be copied from
	tar cf - . | (cd newdirectoryname; tar xpfB -)

NOTE: for both of the above the following applies-
Under BSD-like unixes, you must be root to assign someone else's uid
to a file.  Under SysV you will run into a different problem: when you
create a directory and then change its ownership to someone else, you
might no longer have write permissions.  Hence, you can't create any
files in it. (Thanks Michael)             

Again thanks to everyone who sent mail about this problem!

---
Ken Niedermeyer			| The views expressed above do not represent
Computing Systems Analyst	| those of my employer.... (but when do they?)
Boeing Computer Services (BCS)  | 
                                | NOTICE:
Internet:                       | Lack of planning on your part
kan9691@eeidf002.ca.boeing.com  | does not constitute an emergency on my part.

-- 
Ken Niedermeyer			| NOTICE:
Computing Systems Analyst	| Lack of planning on your part
kan9691@eeidf002.ca.boeing.com	| does not constitute an emergency on my part.
From: wolfgang@wobl.rhein-main.de (Wolfgang Blachnik)
Newsgroups: comp.unix.shell
Subject: Re: How to empty a file
Date: Thu, 03 Sep 92 21:14:25 MESZ
Distribution: world               
Organization: private site in Heusenstamm

ccksb@blaze.trentu.ca (Ken Brown) writes:
>
> I'd like to empty a log file after extracting what I need from it so that
> the next day's data can fill it up a-fresh.  The file must exist after
> emptying it.
> 
> Any suggestions?

   
   > file
   ^^^^^^

wolfgang


-----------------------------------------------------------------------------
Wolfgang Blachnik                     UUCP:       wolfgang@wobl.rhein-main.de
                                      CompuServe: 100013.2353@CompuServe.COM

Newsgroups: comp.unix.shell
From: bandy@aplcen.apl.jhu.edu (Mike Bandy)
Subject: Re: Help with directories!
Organization: Johns Hopkins University
Date: Wed, 26 Aug 92 03:17:42 GMT

ericd@synoptics.com (Eric Davis) writes:

>I am looking for a sh routine to return a numerical value for a file/directory.
>i.e. the files permissions are -rwxr-xr-x it would return a 755.

>NOTE: I am looking just for the parser, I can shove data into it.

>Thanks
>Eric

>P.S. If there is a way to do it with an existing utility, please let me know.


>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>In real life:    Eric Davis
>On the internet: ericd@synoptics.com
>On the air:      KD6HTO
>On packet radio: KD6HTO @ N6IYA.#NOCAL.CA.US.NA

>Invisible airwaves crackle with life.... -Rush
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

I've just read 18 messages regarding this question.  And not one of them
told us the answer (to which I'm curious or I wouldn't have wasted your
precious time with this message)...  Give us a break, and the answer to the
question, and let's get on with our lives ...

	Mike Bandy
	Johns Hopkins University / Applied Physics Lab

Newsgroups: comp.unix.shell
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: Re: Awk question
Originator: dslg0849@uxa.cso.uiuc.edu
Reply-To: d-lewart@uiuc.edu (Daniel S. Lewart)
Organization: University of Illinois at Urbana
Date: Wed, 2 Sep 1992 08:45:14 GMT

brodesky@td2cad.intel.com (Michael Brodesky) writes:

> I would like to get the current year into my awk program. Any
> clues into doing this?

If you have `gawk' with the `strftime' function, then use this:
	#! /usr/local/bin/gawk -f
	BEGIN {
		print strftime("%Y")
	}

If you have `gawk', `nawk', or `awk' with the getline function, then use this:
	#! /bin/awk -f
	BEGIN {
		"date +19%y" | getline y
		print y
		close("date +19%y")
	}

Else use this:
	awk 'BEGIN { print y }' y=`date +19%y`

Daniel Lewart
d-lewart@uiuc.edu