help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sed with Variable Substitution in the command


From: Greg Wooledge
Subject: Re: sed with Variable Substitution in the command
Date: Thu, 26 Sep 2024 14:21:06 -0400

On Thu, Sep 26, 2024 at 20:03:10 +0200, Andreas Kähäri wrote:
> On Thu, Sep 26, 2024 at 01:16:21PM -0400, Greg Wooledge wrote:

> > > On Thursday, September 26, 2024, Wiley Young <wyeth2485@gmail.com> wrote:
> > > > "${1}"
> > > >             "$1" is okay
> > > > "${11}"
> > > >             "$11" is an error

> > $11 would be equivalent to ${1}1 which is not what's intended.
> 
> How do you know it's not intended? ;-) "Intention" is not something that
> can be inferred from the syntax of small fragment of a shell script.

In this case, what we were given by Wiley Young is not a shell script.
It's a document.  The document shows shell syntax in one column, and
gives an explanation or comment in the second column.

The document is telling us that there is a difference between "${11}"
and "$11".  One is right, and the other is an error.

The context of Wiley's post was "when are braces required, and when are
they optional".  ${1} is a case where the braces are optional, while
${11} is a case where they are required.

There is no ambiguity here.  The intent is completely clear.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]