Re: vi in /bin

Previous thread: HALATRAILER / TRAILER HITCH p/ TODO VEHICULO by Autoservicio TSO S.A. on Tuesday, December 15, 2009 - 2:41 pm. (1 message)

Next thread: YOUR EMAIL ADDRESS HAVE WON A PRIZE. by EURO LOTERIA END OF YEAR PROMOTION AWARD on Thursday, December 17, 2009 - 6:08 pm. (1 message)
From: Brad Tilley
Subject: vi in /bin
Date: Thursday, December 17, 2009 - 5:47 pm

I use ed in emergencies when /usr is inaccessible, but I'm a lot more
comfortable with vi. Will a static vi ever live in /bin? Helping someone
use ed remotely, who has never used ed, when I myself don't use it
regularly is always an adventure.

Brad

From: Randal L. Schwartz
Date: Thursday, December 17, 2009 - 6:12 pm

>>>>> "Brad" == Brad Tilley <brad@16systems.com> writes:

Brad> I use ed in emergencies when /usr is inaccessible, but I'm a lot more
Brad> comfortable with vi. Will a static vi ever live in /bin? Helping someone
Brad> use ed remotely, who has never used ed, when I myself don't use it
Brad> regularly is always an adventure.

Solution: learn "ed" a bit more.

It's really *not* that hard. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

From: Brad Tilley
Date: Thursday, December 17, 2009 - 6:23 pm

On Thu, 17 Dec 2009 17:12 -0800, "Randal L. Schwartz"

Good advice. Guess I'm looking for the easy way out. I'll make myself
edit in ed every Friday or something.

Brad

From: Raymond Lillard
Date: Thursday, December 17, 2009 - 8:26 pm

Real men use cat. :-)

From: David Gwynne
Date: Thursday, December 17, 2009 - 10:07 pm

real men use COPY CON PROGRAM.EXE

From: Igor Sobrado
Date: Friday, December 18, 2009 - 2:28 am

real men use EDIT/TECO.

From: Gregory Edigarov
Date: Friday, December 18, 2009 - 3:15 am

On Fri, 18 Dec 2009 10:28:25 +0100
real men use XEDIT.

-- 
With best regards,
	Gregory Edigarov

From: Eugene Yunak
Date: Friday, December 18, 2009 - 7:33 am

REAL men use butterflies

// http://xkcd.com/378/

-- 
The best the little guy can do is what
the little guy does right

From: Nick Bender
Date: Friday, December 18, 2009 - 9:16 am

Real men use punch cards. Paper tape is acceptable for backups...

From: Internet Retard
Date: Friday, December 18, 2009 - 10:10 am

You mean real *Internet* men. In person, these men (for lack of a better word)
are easily de-assified and can be made to cry. However, they are fearless
keyboard warriors while alone, in the dark, dusty corner of their mother's
basement at night. I made one of these Internet Men cry once by scattering his
nicely organized punch card program all over the floor.

Your pal,

IR

_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/soci
al-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010

From: Nick Bender
Date: Friday, December 18, 2009 - 10:55 am

Fail. Real men put sequence numbers in the comment columns
so the card sorter can put them back in order.

-N

From: Chris Bennett
Date: Thursday, December 17, 2009 - 11:09 pm

Just out of curiosity, my "emergencies" usually involve having to edit 
/etc/fstab that has entries that no longer apply after moving disks around.
I just export TERM=xterm, fsck /usr and / mount both rw and vi away

Is there a common emergency that comes up where /usr is not available?

ed is of course on my study list :)
Did ed come out before or after those clickety-clack paper printing 
terminals?

-- 
A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects.
   -- Robert Heinlein

From: Woodchuck
Date: Friday, December 18, 2009 - 12:35 am

On Fri, Dec 18, 2009 at 1:09 AM, Chris Bennett


All text editors came after teletypes. (Teletypes go back to
the 1920's).

Dave "fossil"
-- 
                       This email address is hosted by gmail.
                          Privacy is not an issue with gmail.

From: Philip Guenther
Date: Friday, December 18, 2009 - 12:47 am

Sure, but ed was definitely used with teletypes back in the day.
Consider the first story told by Dennis Ritchie here:

http://cm.bell-labs.com/cm/cs/who/dmr/odd.html

in which a side-effect of using ed with a teletype is involved.


Philip Guenther

From: Paul M
Date: Friday, December 18, 2009 - 3:03 am

In the past, I've kept a basic fstab so that when my disks dont
mount as they should for any reason, I can move /etc/fstab out the
way, replace it with my simple one, and bingo - no editing required.


paulm

From: Dale Rahn
Date: Friday, December 18, 2009 - 8:40 am

When working on changed to the dynamic linker, vi was always the first 
test program (sanity testing). And yes, it broke quite a number of times.

Dale Rahn				drahn@dalerahn.com

From: Pieter Verberne
Date: Friday, December 18, 2009 - 12:36 am

You should also try a teleprinter. I'm not sure where you can get them
these days, and don't know about the price either.

From: Han Boetes
Date: Friday, December 18, 2009 - 1:07 am

I just compiled mg statically and put it in /bin, which is rather
simple:

Add 'LDFLAGS+=-static' somewhere in the makefile with your
favourite editor. And then run:

$ make
$ strip mg
$ ldd mg
$ ls -l mg
$ sudo install mg /bin/mg

400kb! that barely larger than a dynamic vi :-)



# Han

From: Matthew Szudzik
Date: Friday, December 18, 2009 - 8:46 am

If using ed is an "adventure", then you don't really know how to use vi.

ed, sed, and vi are three of the most important Unix utilities, and
there's no excuse for not learning all three.  That's because they all
use the same commands and syntax.  If you know how to use one of them,
then you know how to use the other two.

Each is useful in a slightly different situation.  vi is for interactive
editing.  ed and sed are most useful for writing editing scripts.  ed
reads a file into a buffer for editing and can write those edits back to
the file.  sed works as a filter, reading a stream from standard input
line-by-line and editing each line before writing it to standard output.
Short, one-line sed scripts are useful in command line pipes for
translating the output of one program into the input of another program.

Although most of the basic commands are the same in ed, sed, and vi,
there are subtle differences.  After you have spent some time using ed
and sed, I suggest that you ask yourself the follow questions to test
your understanding of those differences: "When is the global command
(that is, g) useful in ed and vi?  Why is the global command missing
from sed?"

From: Chris Bennett
Date: Friday, December 18, 2009 - 10:30 am

I would like to learn to use sed, however, I did not find that the man 
page was sufficient as a tutorial. I was not able to find any sed 
tutorials that were consistent with OpenBSD's variation.

Does anyone know of any sed tutorials that work with OpenBSD's version?

-- 
A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects.
   -- Robert Heinlein

From: ropers
Date: Friday, December 18, 2009 - 11:22 am

I've personally thus far never bumped into any particular behaviours
that would differentiate OpenBSD's sed(1) command syntax from that of
other implementations. (That could be because of my relative
inexperience, or because there are no substantial differences.)

With that said, this page --which was not authored specifically for
OpenBSD sed(1)-- may be of use:

http://www.grymoire.com/Unix/Sed.html#uh-0

--regards,
ropers

From: Chris Bennett
Date: Friday, December 18, 2009 - 11:35 am

Nope, I ran into many pages like these. OpenBSD doesn't support sed -i

-- 
A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects.
   -- Robert Heinlein

From: Anders Langworthy
Date: Friday, December 18, 2009 - 12:29 pm

On Fri, Dec 18, 2009 at 1:35 PM, Chris Bennett

GNU sed's file-in-place editing is a convenience, but not having it
won't hamper your ability to learn to use sed. This is particularly
true here, as that tutorial makes no mention of 'sed -i'

Cheers,
Anders.

From: Antoine Jacoutot
Date: Friday, December 18, 2009 - 3:57 pm

$ echo foo > blah
$ cat blah 
foo
$ sed -a 's/foo/bar/wblah' blah
bar
$ cat blah
bar


-- 
Antoine

From: Hugo Villeneuve
Date: Monday, December 21, 2009 - 6:37 pm

OpenBSD's sed technicaly supports command concatation with ";" on
the command line but it breaks "branch" without label. Which correctly
branch to the end of the script on GNU sed.

On OpenBSD, to get the same behavior you would need to define a
label as the last instruction and branch to it.

That might be a bug though. (branch without label works as expected
from inline scripts)



-- 
Hugo Villeneuve <hugo@EINTR.net>
http://EINTR.net/ 

From: Matthew Szudzik
Date: Monday, December 21, 2009 - 7:32 pm

Read the caveat at the end of the sed man page:

 "The use of semicolons to separate multiple commands is not permitted
 for the following commands: a, b, c, i, r, t, w, :, and #."

Either use newlines instead of semicolons, or give each line of the
script separately with the -e option.  For example, instead of

 sed 's/a/b/ ; t ; s/c/d/'

use

 sed -e 's/a/b/' -e 't' -e 's/c/d/'

From: Hugo Villeneuve
Date: Friday, December 25, 2009 - 10:59 am

I should have left more quoted text about tutorial from other sed
implementation. 

I had been using gnu sed for a while and encountered this issue

I should read better. Since it's documented, it's not a bug.

Of course that sentence is false. ":" correctly interpret semicolon
as next command. "b" and "t" has partial support (only when the
label is not empty). It is true for the a c i r w #.

Is this one of those few case where I should obey the man page

It's a cute work around. My point is: if a label can't contain
semicolons, why support "tlabel;" and not "t;"? I don't understand
the logic of it.


Don't trust this diff but it make my few test works:

Index: compile.c
===================================================================
RCS file: /cvs/src/usr.bin/sed/compile.c,v
retrieving revision 1.28
diff -u -r1.28 compile.c
--- compile.c	16 Oct 2008 16:34:32 -0000	1.28
+++ compile.c	25 Dec 2009 17:46:49 -0000
@@ -283,7 +283,7 @@
 		case BRANCH:			/* b t */
 			p++;
 			EATSPACE();
-			if (*p == '\0')
+			if (*p == '\0' || *p == ';' )
 				cmd->t = NULL;
 			else
 				cmd->t = duptoeol(p, "branch", &p);

From: Matthew Szudzik
Date: Friday, December 25, 2009 - 11:18 am

Keep in mind that GNU sed is not the standard version of sed, it
contains many nonstandard features.  The standard version of sed is
specified by POSIX.  The places where OpenBSD sed deviates from the
POSIX standard are documented at

 http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sed/POSIX?rev=1.2;content-type=text%...

In particular, that document says that

 "Historic versions of sed permitted commands to be separated
 by semi-colons, e.g. 'sed -ne '1p;2p;3q' printed the first
 three lines of a file.  This is not specified by POSIX.
 Note, the ; command separator is not allowed for the commands
 a, c, i, w, r, :, b, t, # and at the end of a w flag in the s
 command.  This implementation follows historic practice and
 implements the ; separator."

Basically, the semicolons are a nonstandard historic feature.  If you
want your sed scripts to be compatible with all Unix systems, then stick
to the POSIX standard and use newlines or -e to separate commands.

From: Matthew Szudzik
Date: Friday, December 18, 2009 - 11:45 am

I learned sed from the book Sed & Awk by Dougherty and Robbins.

 http://amazon.com/dp/1565922255

I highly recommend it.  Of the three utilities ed, sed, and vi, sed is
probably the most challenging because it doesn't have an interactive
mode.  With ed or vi you can always do something interactively if you
don't know the relevant command, but sed forces you to understand the
commands if you want to get anything done.

Learning sed will make you a better user of ed and vi.

From: Jason McIntyre
Date: Friday, December 18, 2009 - 4:16 pm

the man page is not a tutorial,  but it does document everything. you
can use google and SEE ALSO for other stuff. actually the man page is
surprisingly complete, though i wouldn;t blame you for googling.

everyone else has joked about it, but ed(1) is a braw wee editor... real
mem tire of comparisons.

jmc

From: Otto Moerbeek
Date: Saturday, December 19, 2009 - 1:30 am

I'm aftraid my English (Scottish?) idiom falls short here. But I guess
"braw wee editor" means "small, but fine editor"? Because then you are right,
of course.

	-Otto (who learned ed before any other editor)

From: Jason McIntyre
Date: Saturday, December 19, 2009 - 2:01 am

yes, it really means "a great little editor". although putting "great"
and "little" together sounds all wrong.

anyway, i was drunk when i wrote that. otherwise i would have ignored
this stupid thread.

jmc

From: Randal L. Schwartz
Date: Friday, December 18, 2009 - 4:27 pm

>>>>> "Matthew" == Matthew Szudzik <mszudzik@andrew.cmu.edu> writes:

Matthew> ed, sed, and vi are three of the most important Unix utilities, and
Matthew> there's no excuse for not learning all three.  That's because they all
Matthew> use the same commands and syntax.  If you know how to use one of them,
Matthew> then you know how to use the other two.

Everything I used to know about sed, I've forgotten once learning Perl.

There's really no excuse for not knowing Perl and Python these days.

And if you need to learn Perl, I can recommend a good book (or two :).

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

From: Ingo Schwarze
Date: Friday, December 18, 2009 - 5:33 pm

That's bad: sed is still needed, see /usr/src/distrib/miniroot/list
for a striking example.

That said, liking and using Perl a lot, the same happens to me,
but i see that as deficiency, not a virtue.

From: Paul M
Date: Saturday, December 19, 2009 - 12:30 am

You can do anything in Perl.
Tho' it's never the right tool for the job.


pailm

From: Henning Brauer
Date: Saturday, December 19, 2009 - 5:13 am

any excuse to not know python is a good and valid one. any.

-- 
Henning Brauer, hb@bsws.de, henning@openbsd.org
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting

From: Matthew Szudzik
Date: Saturday, December 19, 2009 - 10:34 am

It seems that every decade has its own fashionable Unix scripting
language.  The original scripting language, used in the 1970's was sed.
But awk became the fashionable language in the 1980's, then perl in the
1990's, and now python in the 2000's.  Who knows what will be next?

If you have time to spare, it certainly could be useful to learn all of
these languages.  But if you're going to learn just one of them, then I
vote for sed.  You will still encounter environments where sed is the
only one of these languages available (as Ingo pointed out, the OpenBSD
installer is one such example).

It isn't really necessary to keep up with fashion, you can just stick
with the historical standards.

From: Ingo Schwarze
Date: Saturday, December 19, 2009 - 10:51 am

Marc, rewrite pkg* in sed.  Please... :)

Previous thread: HALATRAILER / TRAILER HITCH p/ TODO VEHICULO by Autoservicio TSO S.A. on Tuesday, December 15, 2009 - 2:41 pm. (1 message)

Next thread: YOUR EMAIL ADDRESS HAVE WON A PRIZE. by EURO LOTERIA END OF YEAR PROMOTION AWARD on Thursday, December 17, 2009 - 6:08 pm. (1 message)