[comp.sys.apple] Long stuff using Unix scripts and aliases for a better life.

kamath@reed.UUCP (Sean Kamath) (02/26/89)

ACK!  I'm being plagued with horrid little shell scripts and aliases thiss
week . . .

In article <147@cires.colorado.edu> rob@cires.Colorado.EDU (Rob Cuthbertson) writes:
>
>Unix people, stick this in your .cshrc:
>---Cut Here---
>alias nl2cr     "cat \!^ | tr '\012' '\015' > \!^.X ; rm -f \!^ ; mv \!^.X \!^"
>alias cr2nl     "cat \!^ | tr '\015' '\012' > \!^.X ; rm -f \!^ ; mv \!^.X \!^"
>
>#Before you download a Unix file to your Apple, type "nl2cr <file>" and after
>#you upload an Apple file to the Unix system type "cr2nl <file>".  Takes care
>#of the incompatibilities between the Apple and Unix line delimiters.

This will work, of course.  But just like the 200 lines of shell script
written in "Tricks of the Unix Master" to do base conversions, it's a bit of
a waste. (in it, the write 7 files.  Each file will convert from one base to
another, with one controlling base.  As any good C-hacker knows, it's a 6
line program. . .)

Beides being horribly redundant, it adds two unneccessary layers.

alias nl2cr "tr '\012' '\015' < \!^ > \!^.X ; mv \!^.X \!^"

and similarly for cr2nl.

However, I find it easier to do the following:  Write a shell script that
takes files, converts then to cr's, then downloads them.  I.e.

---
#!/bin/sh

mkdir /tmp/download.$$
for i in $*
do
tr '\012' '\015' < $i > /tmp/download.$$/$i
done

ymodem /tmp/donwload.$$/??*

rm -rf /tmp/download.$$
--

Of course, this was very short, doesn't handle files in other directories,
etc.  Also, it's designed more for ymodem than xmodem, though in xmodem you
stuff the "xmodem" command in after the "tr".  Thes you just have to sit
there and be ready for each file.  Or you can do weird stuff with flags,
beep and the like.

I like to make aliases for *reading* the file, such as amore (alias more tr
... < \!* | more).

Oh, and for the guy who kept getting "more (23%)" at the end very page, try
using "cat".

Sean Kamath
-- 
UUCP:  {decvax allegra ucbcad ucbvax hplabs}!tektronix!reed!kamath
CSNET: reed!kamath@Tektronix.CSNET  ||  BITNET: kamath@reed.BITNET
ARPA: kamath%reed.bitnet@cunyvm.cuny.edu
US Snail: 3934 SE Boise, Portland, OR  97202-3126 (I hate 4 line .sigs!)