Welcome, Guest. Please login or register.

Author Topic: Has anybody used the "Edit" shell command in recent years, and/or knows what it does?  (Read 4899 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline olsenTopic starter

The "Edit" shell command is one of the odder of the odd AmigaDOS shell commands. It's supposed to be a line editor which reads a file and then modifies it according to control commands which one can either enter manually, or have them read from a file. It's basically the AmigaDOS version of the Unix "sed" (stream editor) command.

As a matter of fact, the "Edit" command introduced with Workbench 2.0 never actually worked correctly. It either corrupted the files it read or crashed. Also, the documented features (e.g. in the AmigaDOS manual, 3rd edition) were not all implemented either. Which means that the command was basically useless, and has been for the past 20 or so years.

I'm curious if anybody here has ever used the "Edit" command, or even knows about its existance.
 

Offline zipper

Probably I tried it in early 90's but as ed did so much more it was used until I found other, better editors. Can't remember if any problems popped up.
 

Offline olsenTopic starter

Quote from: zipper;635042
Probably I tried it in early 90's but as ed did so much more it was used until I found other, better editors. Can't remember if any problems popped up.


Interesting. "Edit" is sort of a precursor to the full-screen editors such as "Ed". While it does have an interactive mode of sorts, "Edit" isn't as useful as "Ed" for interactive operations. The point of having "Edit" is to give it instructions on how to modify the file being edited. As such it was supposed to be useful in script files, which "Ed" is not.
 

Offline kolla

Old thread revival :)

Yes, I have used Edit quite a bit, and never really had any issue with it crashing. It is truly a fun adventure to use it, sort of like a text adventure of the board game "Roborally", hehe.
B5D6A1D019D5D45BCC56F4782AC220D8B3E2A6CC
---
A3000/060CSPPC+CVPPC/128MB + 256MB BigRAM/Deneb USB
A4000/CS060/Mediator4000Di/Voodoo5/128MB
A1200/Blz1260/IndyAGA/192MB
A1200/Blz1260/64MB
A1200/Blz1230III/32MB
A1200/ACA1221
A600/V600v2/Subway USB
A600/Apollo630/32MB
A600/A6095
CD32/SX32/32MB/Plipbox
CD32/TF328
A500/V500v2
A500/MTec520
CDTV
MiSTer, MiST, FleaFPGAs and original Minimig
Peg1, SAM440 and Mac minis with MorphOS
 

Offline pyrre

Quote from: olsen;635040
The "Edit" shell command is one of the odder of the odd AmigaDOS shell commands. It's supposed to be a line editor which reads a file and then modifies it according to control commands which one can either enter manually, or have them read from a file. It's basically the AmigaDOS version of the Unix "sed" (stream editor) command.

As a matter of fact, the "Edit" command introduced with Workbench 2.0 never actually worked correctly. It either corrupted the files it read or crashed. Also, the documented features (e.g. in the AmigaDOS manual, 3rd edition) were not all implemented either. Which means that the command was basically useless, and has been for the past 20 or so years.

I'm curious if anybody here has ever used the "Edit" command, or even knows about its existance.
I always used CED for such work....
Amiga 1200 Tower Os 3.9
BPPC 603e+ 040-25/200, 256MBram, BVIsionPPC, Indivision AGA MK2.
Amiga 2000 (rev 4.0) Os 1.2/1.3
2088 bridgeboard, 2MB ram card, 2091 SCSI.
Amiga 500+ Os 2.1
Derringer 030, 32MBram, Buddha in sidecar, Indivision ECS.
Amiga CD32
Video decoder
 

guest11527

  • Guest
Quote from: pyrre;806588
I always used CED for such work....

Well, the purpose of EDIT is rather to automate edits for scripting, and for that CED is not well suited. EDIT could, in principle, do this. However, it's arcane syntax is not really helpful.  I personally use my edition of SED for this purpose - the syntax is probably not less arcane, though based on the AmigaDos wildcards, but at least the beast works.
 

Offline kolla

One thing I recall using edit for fairly recently, was editing output from C:date command, to "translate" them to strings that c:date would understand as input. Output from c:date is always localized, but it _only_ accepts English input, so names of months have to be replaced. I had a timestamp file that was written to regularly, and on boot, the content would be parsed through edit and fed to c:date. Later I went to not using content, but only the timestamp of the file, using c:setdate to "touch" the file with a new timestamp every now and then. Ideally I wish C:setdate could "touch" the filesystem creation date too, which AmigaOS uses as start time for systems without RTC, and/or that C:date could set system time based on the timestamp of a file/filesystem. A small gem on aminet btw, is http://aminet.net/package/util/time/TimeKeeper  .
« Last Edit: March 31, 2016, 03:25:53 PM by kolla »
B5D6A1D019D5D45BCC56F4782AC220D8B3E2A6CC
---
A3000/060CSPPC+CVPPC/128MB + 256MB BigRAM/Deneb USB
A4000/CS060/Mediator4000Di/Voodoo5/128MB
A1200/Blz1260/IndyAGA/192MB
A1200/Blz1260/64MB
A1200/Blz1230III/32MB
A1200/ACA1221
A600/V600v2/Subway USB
A600/Apollo630/32MB
A600/A6095
CD32/SX32/32MB/Plipbox
CD32/TF328
A500/V500v2
A500/MTec520
CDTV
MiSTer, MiST, FleaFPGAs and original Minimig
Peg1, SAM440 and Mac minis with MorphOS
 

Offline Gulliver

I currently use edit in my installation scripts to make modifications to the startup-sequence without user intervention.

This saves me, and the not so skillfull users a lot of grief.

It is indeed a very powerfull tool that often gets overlooked.
 

Offline Mazze

  • Full Member
  • ***
  • Join Date: Aug 2007
  • Posts: 133
    • Show only replies by Mazze
    • http://mazze-online.de
The only command I ever used was "q" to quit when I unintended started the editor ;-)

Offline kolla

B5D6A1D019D5D45BCC56F4782AC220D8B3E2A6CC
---
A3000/060CSPPC+CVPPC/128MB + 256MB BigRAM/Deneb USB
A4000/CS060/Mediator4000Di/Voodoo5/128MB
A1200/Blz1260/IndyAGA/192MB
A1200/Blz1260/64MB
A1200/Blz1230III/32MB
A1200/ACA1221
A600/V600v2/Subway USB
A600/Apollo630/32MB
A600/A6095
CD32/SX32/32MB/Plipbox
CD32/TF328
A500/V500v2
A500/MTec520
CDTV
MiSTer, MiST, FleaFPGAs and original Minimig
Peg1, SAM440 and Mac minis with MorphOS
 

Offline save2600

  • Hero Member
  • *****
  • Join Date: Jul 2006
  • Posts: 3261
  • Country: us
    • Show only replies by save2600
Yeah, Edit has always been a bit of a mystery to me too. Use Ed all_the_time though to modify my startup-sequences, text files, etc. Just be sure to delete the Ed-Startup file in S for a little more GUI flexibility.
 

Offline Gulliver

I only used the insert feature of the edit command with some search and line position placement. Nothing too complex, but never encountered the bugs that olsen claims it has.

Most likely I was just lucky.
 

Offline olsenTopic starter

Quote from: Gulliver;806624
Most likely I was just lucky.
That's probably the best explanation ;-)

The reason why I asked my question back in 2011 was because after long deliberation I had decided to take the plunge and try to port the "Edit" shell command properly to AmigaOS4, making it reentrant.

During the course of this exercise I discovered that the AmigaOS 2.0 version was something of an odd port of the original BCPL version. Its companion, the "Ed" editor, fared much better in terms of how it was ported. Both "Edit" and "Ed" share some architectural decisions with regard to how the text is stored and modified in memory. The text is basically one big lump of memory which is chopped up into lines, with pointers referring to where the individual lines begin.

The problem with "Edit" was that how the text data was stored was inconsistent. In parts "Edit" wanted to treat the text as 'C' style NUL-terminated strings, in others it wanted it to be BCPL strings. It probably didn't help that the documentation for the command was somewhat inconsistent, too.

Anyway, when I was finished reworking the code I was uncertain if just maybe I had accidentally made something work correctly, and which might cause problems with users who had adapted to the quirks of the program over the years. "Edit" was supposed to be a command used exclusively in shell scripts, which would have aggravated the problem of "things now working differently than before", because shell scripts are notoriously difficult to debug.

So far it seems that my worries may have been unfounded. From my impressions whoever used "Edit" would limit the use of the command to those operations which didn't easily corrupt data or cause it to crash. Those commands still work as they did in the reworked version.

What works better now than before (read: doesn't crash, doesn't corrupt data), however, makes you realize how limited the "Edit" command is in what it does. The humble Unix "sed" is more powerful than "Edit" could be in its current form.
 

Offline kolla

In my view, sed and edit are different beasts - sed is a "stream editor", working on data streams, while edit is more like a normal editor, except you are pretty much editing blindly. The UNIX equivalent of Amiga "edit" would be "ed".
B5D6A1D019D5D45BCC56F4782AC220D8B3E2A6CC
---
A3000/060CSPPC+CVPPC/128MB + 256MB BigRAM/Deneb USB
A4000/CS060/Mediator4000Di/Voodoo5/128MB
A1200/Blz1260/IndyAGA/192MB
A1200/Blz1260/64MB
A1200/Blz1230III/32MB
A1200/ACA1221
A600/V600v2/Subway USB
A600/Apollo630/32MB
A600/A6095
CD32/SX32/32MB/Plipbox
CD32/TF328
A500/V500v2
A500/MTec520
CDTV
MiSTer, MiST, FleaFPGAs and original Minimig
Peg1, SAM440 and Mac minis with MorphOS
 

guest11527

  • Guest
Quote from: kolla;806643
In my view, sed and edit are different beasts - sed is a "stream editor", working on data streams, while edit is more like a normal editor, except you are pretty much editing blindly. The UNIX equivalent of Amiga "edit" would be "ed".

"edit" can certainly be run in non-interactive mode by proper redirection, and as far as I understand, that's the intended purpose. Otherwise, the "user interface" is pretty much a joke.

Except that it is too limited to be really useful. It's one of the left-overs from original tripos. Get "SED" from the aminet, does its job and is more powerful.