zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>,
	Marc Chantreux <eiro@phear.org>,  Zsh Users <zsh-users@zsh.org>
Subject: Re: autoload variables
Date: Thu, 2 Sep 2021 17:07:54 -0700	[thread overview]
Message-ID: <CAH+w=7b9FyeEMkeW8j8nMUrM15_-Eu9_FAm=-dGSZkSH913yrQ@mail.gmail.com> (raw)
In-Reply-To: <YTFZvrv6O8HBW3R6@teapot.bifb.org>

On Thu, Sep 2, 2021 at 4:10 PM Anthony Fletcher <anthony@bifb.org> wrote:
>
> > > >   sed -n -e '/^default/ s/^default.*dev //; s/ .*// p;q'

To start out with, if this is GNU sed, that trailing ";q" means that
at most one line will be processed, and then sed will stop.  So this
is going to print either one or zero lines.  One line will be printed
if s/ .*//p matches the first line of input, otherwise nothing will
be.

In front of that, /^default/ means to consider lines that begin with
default as candidates for s/^default.*dev// -- but lines that don't
match /^default/ also won't have anything changed by that s///, so
either it should move on to the s///p and then q(uit).

> 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.

If that's true, then you have not accurately copy-pasted your sed
command in the original example.

If the command were this:

sed -n -e '/^default/{s/^default.*dev //; s/ .*// p;q;}'

Then the braces group the expressions that are separated by
semicolons, and you'll skip every line up to the first one that
matches /^default/ and then apply the two s/// to that before quitting
(again with exactly one or zero lines of output).  In that instance
the leading /^default/ matters.


  reply	other threads:[~2021-09-03  0:08 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 [this message]
2021-09-03  6:52           ` Marc Chantreux

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='CAH+w=7b9FyeEMkeW8j8nMUrM15_-Eu9_FAm=-dGSZkSH913yrQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=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).