Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #231229

Re: URL to source file

From Vincent Lefevre <vincent@vinc17.net>
Newsgroups linux.debian.user
Subject Re: URL to source file
Date 2021-01-28 15:40 +0100
Message-ID <BCgCJ-2Gy-5@gated-at.bofh.it> (permalink)
References (5 earlier) <BBQRZ-3Su-23@gated-at.bofh.it> <BBRkZ-41M-3@gated-at.bofh.it> <BBTmN-5bT-9@gated-at.bofh.it> <BC4ie-3Dx-1@gated-at.bofh.it> <BCfnk-20K-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 2021-01-28 08:07:51 -0500, Greg Wooledge wrote:
> On Thu, Jan 28, 2021 at 02:26:47AM +0100, Vincent Lefevre wrote:
> >   print -r ${${(M)${(f)"$(aptitude show units)"}:#Version:*}#* }
> 
> I have one major objection to this: how do you handle a package that
> has more than one version available?
> 
> unicorn:~$ apt-cache show firefox-esr | grep ^Version:
> Version: 78.7.0esr-1~deb10u1
> Version: 78.5.0esr-1~deb10u1

The units package has 2 versions available:

zira:~> apt-cache show units | grep "^Version:"
Version: 2.21-1
Version: 2.18-1

but "aptitude show units" only returns one of them (the preferred one,
I suppose). So, no issues with my code.

In my previous message, I also gave the equivalent with apt-cache,
by using the --no-all-versions option.

[...]
> One of the advantages of this version over the zsh version is that it
> doesn't need to read the whole output of aptitude into memory all at
> once.

Note that with zsh, one can also do a process substitution. However,
I would tend to say that process substitution is more complex and
would have more overhead. At least there are more system calls with
bash:

zira:~> strace -f -o str.out bash -c 'v=$(date)' ; wc -l str.out
471 str.out

zira:~> strace -f -o str.out bash -c ': < <(date)' ; wc -l str.out
535 str.out

So I would say that command substitution is here more efficient.

Not much difference with zsh, though:

zira:~> strace -f -o str.out zsh -fc 'v=$(date)' ; wc -l str.out
725 str.out

zira:~> strace -f -o str.out zsh -fc ': < <(date)' ; wc -l str.out
726 str.out

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-27 10:30 +0100
  Re: URL to source file <tomas@tuxteam.de> - 2021-01-27 10:40 +0100
    Re: URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-27 11:00 +0100
      Re: URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-27 11:10 +0100
        Re: URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-27 11:20 +0100
          Re: URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-27 11:50 +0100
            Re: URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-27 12:10 +0100
              Re: URL to source file Vincent Lefevre <vincent@vinc17.net> - 2021-01-27 12:40 +0100
                Re: URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-27 14:50 +0100
                Re: URL to source file Vincent Lefevre <vincent@vinc17.net> - 2021-01-28 02:30 +0100
                Re: URL to source file Greg Wooledge <wooledg@eeg.ccf.org> - 2021-01-28 14:20 +0100
                Re: URL to source file Vincent Lefevre <vincent@vinc17.net> - 2021-01-28 15:40 +0100
                Re: URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-29 05:00 +0100
                Re: URL to source file Andrei POPESCU <andreimpopescu@gmail.com> - 2021-01-27 17:10 +0100
      Re: URL to source file <tomas@tuxteam.de> - 2021-01-27 11:30 +0100
      Re: URL to source file Stefan Monnier <monnier@iro.umontreal.ca> - 2021-01-27 16:00 +0100
        Re: URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-27 16:20 +0100
        Re: URL to source file Emanuel Berg <moasenwood@zoho.eu> - 2021-01-27 16:30 +0100

csiph-web