From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: line continuation with sed
Date: Fri, 14 Oct 2022 08:44:08 -0700 [thread overview]
Message-ID: <aef3a3e5-cdc3-01a8-6a3c-013c3ac31384@eastlink.ca> (raw)
In-Reply-To: <Y0lF8/Z5jwjfTeSa@localhost>
Thanks for the replies all:
$ ls filename\ ending\ with\ a\ space\ <enter>
Ok, so it's an overload of the backslash, which might mean an escaped character, or might indicate line continuation. I think in my example there'd be no difference but I understand your example where ... mind, people who end a filename with a space aren't fit to live ... but linux isn't going to stop you from doing it, so that case must be accommodated. So then *only* 'backslash-newline' is a line continuation and any other variant leaves the backslash as an escape, yes?
Playing with it a bit more, sending the command to history and then recalling it I see the defect:
$ junk="now is the time
for all good men
to come to the aid
of the party"
... now run this script:
aa="print -l ${(q)junk} | sed \
-nre s/all/most/p \
-e s/men/persons/p \
-e s/aid/assistance/p"
print -rS "$aa"
eval $aa
... and get:
$ . test
for most good men
for most good persons
to come to the assistance
... recalling from history it works fine, but if I modify the '$aa' command with the 'backslash-space-newline' the recalled command looks like this:
print -l now\ is\ the\ time$'\n'for\ all\ good\ men$'\n'to\ come\ to\ the\ aid$'\n'of\ the\ party | sed -nre s/all/most/p -e s/men/persons/p \
-e s/aid/assistance/p
... so the bleeding backslash is literal ... I guess that's because the space does not 'escape'? ... but I thought you could put a backslash before any character? Anyway we get a literal backslash and then a literal newline and naturally things go sour. All this to accommodate servants of the Evil One who would end a filename with a space!
Seriously, I get it, thanks guys. I don't like it, but i can see what gets feed to sed, and why it goes wrong, invisibly.
Peter:
You can configure a number of editors to show this up. In emacs,
for example, I use:
(setq-default show-trailing-whitespace t)
... I know it, but after my Debian upgrade whereas my editor used to show a nice little 'return' character/icon, it now shows a 'LF" backlit in white that's so annoying I turned it off :( ... so I'm a victim of that mistake. I'd normally remove trailing spaces just to be tidy, nevermind disasters like the above.
next prev parent reply other threads:[~2022-10-14 15:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 18:25 Ray Andrews
2022-10-14 6:35 ` Lawrence Velázquez
2022-10-14 11:20 ` Dominik Vogt
2022-10-14 15:44 ` Ray Andrews [this message]
2022-10-14 17:10 ` Dominik Vogt
2022-10-14 20:38 ` Lawrence Velázquez
2022-10-14 22:26 ` Ray Andrews
2022-10-14 10:57 ` Marc Chantreux
2022-10-14 11:19 ` Peter Stephenson
2022-10-14 17:15 ` Dominik Vogt
2022-10-14 22:21 ` Ray Andrews
2022-10-15 2:34 ` Aaron Schrab
2022-10-15 2:57 ` Ray Andrews
2022-10-15 5:08 ` Bart Schaefer
2022-10-15 16:53 ` Ray Andrews
2022-10-17 1:07 ` Bart Schaefer
2022-10-17 3:40 ` Ray Andrews
2022-10-17 4:20 ` Bart Schaefer
2022-10-17 9:19 ` Pier Paolo Grassi
2022-10-17 9:24 ` Pier Paolo Grassi
2022-10-17 9:31 ` Pier Paolo Grassi
2022-10-17 16:11 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aef3a3e5-cdc3-01a8-6a3c-013c3ac31384@eastlink.ca \
--to=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).