From: Marc Chantreux <eiro@phear.org>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>,
Zsh Users <zsh-users@zsh.org>
Subject: Re: autoload variables
Date: Fri, 3 Sep 2021 08:52:24 +0200 [thread overview]
Message-ID: <YTHGKHk7Sjq0VQea@prometheus.u-strasbg.fr> (raw)
In-Reply-To: <YTFZvrv6O8HBW3R6@teapot.bifb.org>
> > > Le Tue, Aug 31, 2021 at 11:03:39PM +0200, Roman Perepelitsa a écrit :
> > > english is fine. can you confirm that '/^default/ s/^default.*dev //'
> > > is a suttered way to say 's/^default.*dev //' ?
> >
> > Yes, these are equivalent. Anything that matches '^default.*dev '
> > matches '^default'.
>
> Yes but the point is I am only interested in lines that start with
> 'default via'. I am ignoring all the other lines. Without the initial
> match /^default/ all the other lines are processed by the
> substitutions and I get the wrong interface.
there is no point of repeating yourself without leaving the lhs part
empty. What you just wrote is
* find default at the begin of the line
* find it *again then let's substitute something containing default
if you wanted to ignore a line, your sed script miss the d command
(i used it in the version i proposed):
/^default/d
stop the processing of this line (including the default p ending)
if it match.
/^default/!d
stop the processing of this line (including the default p ending)
if *don't* match.
also: sed keeps the track of its last match which can be called with an
empty lhs. so:
/^default.*dev/!d ; s///
means:
* don't process the lines that don't match the pattern
* as it matched, remove the matched part
> > This requires a new-enough version of ip to support json output.
> Cool - I didn't know JSON output was an option. Not that jq is much less
> baroque than sed. I think this is better than my sed script.
* sed is for text.
* jq is for datastructures serialized in json (i wish there will be a
cbor backend at some point).
> One point in favour of sed - it's then on all systems, jq isn't.
sed is made to be a simple tool inside a pipe or from an editor: it
completes an ecosystem.
jq is a good query langage (baroque as well) but just for json.
> Sorry for the off-topic discussion.
this is my "fault" as i was the one who asked for your sed command.
To me this isn't off-topic at all: zsh is about gluing commands
and sed is both powerful and popular enough so any zsh user should
know a bit of sed.
regards
marc
prev parent reply other threads:[~2021-09-03 6:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-30 15:22 Anthony Fletcher
2021-08-30 15:41 ` Roman Perepelitsa
2021-08-30 16:40 ` René Neumann
2021-08-30 16:57 ` Anthony Fletcher
2021-08-30 19:30 ` Mikael Magnusson
2021-08-30 21:34 ` René Neumann
2021-08-30 21:46 ` Bart Schaefer
2021-08-31 0:10 ` Anthony Fletcher
2021-08-31 18:11 ` Roman Perepelitsa
2021-08-31 19:16 ` Bart Schaefer
2021-08-30 16:49 ` Bart Schaefer
2021-08-31 20:37 ` Marc Chantreux
2021-08-31 21:03 ` Roman Perepelitsa
2021-09-01 8:29 ` Marc Chantreux
2021-09-01 9:51 ` Roman Perepelitsa
2021-09-01 10:06 ` Marc Chantreux
2021-09-01 13:52 ` Bart Schaefer
2021-09-02 23:09 ` Anthony Fletcher
2021-09-03 0:07 ` Bart Schaefer
2021-09-03 6:52 ` Marc Chantreux [this message]
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=YTHGKHk7Sjq0VQea@prometheus.u-strasbg.fr \
--to=eiro@phear.org \
--cc=roman.perepelitsa@gmail.com \
--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).