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


Groups > linux.debian.user > #208368

Shell game? was Re: pmount could perhaps be of greater utility?

From David Wright <deblis@lionunicorn.co.uk>
Newsgroups linux.debian.user
Subject Shell game? was Re: pmount could perhaps be of greater utility?
Date 2019-05-07 21:00 +0200
Message-ID <xVdtM-78o-9@gated-at.bofh.it> (permalink)
References <xTWEF-um-3@gated-at.bofh.it> <xU1l0-3hV-3@gated-at.bofh.it> <xULxw-6Gw-9@gated-at.bofh.it> <xUMjU-6Xr-17@gated-at.bofh.it> <xUVZT-4Jf-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue 07 May 2019 at 10:12:10 (+1000), David wrote:
> On Mon, 6 May 2019 at 23:53, Erik Christiansen <dvalin@internode.on.net> wrote:
> > On 06.05.19 09:03, Greg Wooledge wrote:
> > > On Sat, May 04, 2019 at 01:48:01PM +0200, Jonas Smedegaard wrote:
> > > > Quoting Erik Christiansen (2019-05-04 08:43:53)
> 
> > > > >      pmount $1 `e2label $1`
> 
> > > and is using the ancient deprecated command substitution syntax (which
> > > will work in this case, but is not a good habit).
> 
> > That does appear to remain opinion. The venerably traditional syntax is
> > still fully legal supported bash syntax, e.g.:
> >
> > http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_03
> >
> > The recent (late last century, IIRC) introduction of the $(...)
> > alternative syntax has admittedly brought newer *nix users who know
> > nothing else, and so delude themselves that there is nothing else. That
> > is a misapprehension. To each, his own, especially amongst adequately
> > equivalent alternatives.
> 
> Hi Erik
> 
> Maybe you would enjoy answering this question then?
> https://lists.gnu.org/archive/html/help-bash/2019-05/msg00000.html
> 
> Because apparently no-one else has, hehe :D

My take on this problem goes as follows.

B is easy. man bash says "When the old-style backquote form of
substitution is used, backslash retains its literal meaning except
when followed by $, `, or \." So the \\ in B's inner echo becomes
\ in the outer echo. BB shows the result of running the outer echo
on the substitution made in B.

A is tricky, mainly because of the middle Quotation Mark¹. So the first
thing I would do is substitute a benign character, like x. The result
of that substitution is shown at J. Work with that, and then change x
back to Quotation Mark at the end.

So K runs the inner echo and shows the result. L then runs the outer
echo on that result (leaving out the [] brackets). Because \x is
meaningless in double quotes, it survives the outer echo untouched.

Now put back the Quotation Mark in place of x. man bash says "A double
quote may be quoted within double quotes by preceding it with a
backslash." And that's what we've got in M.

Now working outwards, I've added the [] brackets at LL and MM, where
they play no role. Finally the outer double quotes: because they pair
up with the double quotes from L, that leaves the \x exposed to the
outer echo and it becomes just x.

Who processed the \" into " in A? The outer echo (or, if you like, the
shell handing the arguments to the outer echo).

Over to Greg for checking.

¹ Quotation Mark rather than double quote because it never plays the
role of an active double quote as far as bash is concerned.

Cheers,
David.

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


Thread

pmount could perhaps be of greater utility? Erik Christiansen <dvalin@internode.on.net> - 2019-05-04 08:50 +0200
  Re: pmount could perhaps be of greater utility? Jonas Smedegaard <jonas@jones.dk> - 2019-05-04 13:50 +0200
    Re: pmount could perhaps be of greater utility? Greg Wooledge <wooledg@eeg.ccf.org> - 2019-05-06 15:10 +0200
      Re: pmount could perhaps be of greater utility? Erik Christiansen <dvalin@internode.on.net> - 2019-05-06 16:00 +0200
        Re: pmount could perhaps be of greater utility? David <bouncingcats@gmail.com> - 2019-05-07 02:20 +0200
          Re: pmount could perhaps be of greater utility? Erik Christiansen <dvalin@internode.on.net> - 2019-05-07 06:10 +0200
            Netiquette [Was: Re: pmount could perhaps be of greater utility? Erik Christiansen <dvalin@internode.on.net> - 2019-05-07 14:50 +0200
              Re: Netiquette [Was: Re: pmount could perhaps be of greater utility? rhkramer@gmail.com - 2019-05-07 15:10 +0200
                Re: Netiquette [Was: Re: pmount could perhaps be of greater utility? Erik Christiansen <dvalin@internode.on.net> - 2019-05-08 05:30 +0200
          Re: pmount could perhaps be of greater utility? Greg Wooledge <wooledg@eeg.ccf.org> - 2019-05-07 14:20 +0200
            Re: pmount could perhaps be of greater utility? David <bouncingcats@gmail.com> - 2019-05-19 07:10 +0200
          Shell game? was Re: pmount could perhaps be of greater utility? David Wright <deblis@lionunicorn.co.uk> - 2019-05-07 21:00 +0200
            Re: Shell game? was Re: pmount could perhaps be of greater utility? KHMan <keinhong@gmail.com> - 2019-05-08 08:10 +0200
              Re: Shell game? was Re: pmount could perhaps be of greater utility? David Wright <deblis@lionunicorn.co.uk> - 2019-05-08 18:40 +0200
                Re: Shell game? was Re: pmount could perhaps be of greater utility? KHMan <keinhong@gmail.com> - 2019-05-08 20:10 +0200
    Remove nautilus to stop automounts? [Was: Re: pmount could perhaps  be of greater utility? Erik Christiansen <dvalin@internode.on.net> - 2019-05-07 13:40 +0200
      Re: Remove nautilus to stop automounts? [Was: Re: pmount could  perhaps be of greater utility? Brian <ad44@cityscape.co.uk> - 2019-05-07 14:00 +0200
  Re: pmount could perhaps be of greater utility? Eric S Fraga <e.fraga@ucl.ac.uk> - 2019-05-11 15:40 +0200
    Re: pmount could perhaps be of greater utility? Erik Christiansen <dvalin@internode.on.net> - 2019-05-12 10:00 +0200
      Re: pmount could perhaps be of greater utility? Eric S Fraga <e.fraga@ucl.ac.uk> - 2019-05-12 14:50 +0200
        Re: pmount could perhaps be of greater utility? Erik Christiansen <dvalin@internode.on.net> - 2019-05-12 15:40 +0200
          Re: pmount could perhaps be of greater utility? Eric S Fraga <e.fraga@ucl.ac.uk> - 2019-05-12 21:30 +0200
          Re: pmount could perhaps be of greater utility? David Wright <deblis@lionunicorn.co.uk> - 2019-05-15 06:40 +0200
      Re: pmount could perhaps be of greater utility? Eric S Fraga <e.fraga@ucl.ac.uk> - 2019-05-12 15:00 +0200
      Re: pmount could perhaps be of greater utility? Greg Wooledge <wooledg@eeg.ccf.org> - 2019-05-13 15:10 +0200

csiph-web