bug-ed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Would this have any potential unwanted side-effects?


From: Zeke Williams
Subject: Would this have any potential unwanted side-effects?
Date: Sun, 26 Nov 2023 15:41:12 -0500

I've really been skimming through the manual as of today. It says for
using the w command in GNU ed:

'(1,$)w file
Writes the addressed lines to file. Any previous contents of file are
lost without warning. If there is no default filename, then the
default filename is set to file, otherwise it is unchanged. If no
filename is specified, then the default filename is used. The current
address is unchanged.

If file is prefixed with a bang (!), then it is interpreted as a shell
command and the addressed lines are written to its standard input,
(see shell escape command '!' below). In this case the default
filename is unchanged. Writing the buffer to a shell command does not
prevent the warning to the user if an attempt is made to overwrite or
discard the buffer via the 'e' or 'q' commands. To write to a file
whose name begins with a bang, prefix the name with ./.'

Testing this out, instead of writing the contents of the buffer into a
file on the disk, it redirects the address range as stdin to an
external program if said filename starts with an exclamation mark.
1,$w !less would be an example to read the entire buffer into less
without saving it at all. But is that really what happens? I want to
ensure this is happening exactly as I think it is happening. Because
if yes, the idea of putting ANSI escape sequences into ed will be
completely not necessary. I could just redirect the address range of
the buffer to read it cleanly, even if I did not save it at all by
starting ed without a filename. If there is any potential side-effects
to redirecting to less, let me know. I thank you for your time, and
have a happy hacking.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]