From: Greg Wooledge
To: bug-bash
Subject: Re: parameter expansion with `:` does not work
Date: 08/07/2021 05:58:57 Europe/Paris
On Thu, Jul 08, 2021 at 04:38:25AM +0200, lisa-as...@perso.be wrote:
> I'd rather understand what's going on, rather than simply never use it.
OK. Let
>From: Lawrence Velázquez
>To: lisa-as...@perso.be
>Subject: Re: parameter expansion with `:` does not work
>Date: 08/07/2021 05:23:48 Europe/Paris
>Cc: bug-bash@gnu.org
>> On Jul 7, 2021, at 10:38 PM, lisa-as...@perso.be wrote:
>>
>> Correct. How do oth
On Thu, Jul 08, 2021 at 04:38:25AM +0200, lisa-as...@perso.be wrote:
> I'd rather understand what's going on, rather than simply never use it.
OK. Let's start from the beginning.
In sh and bash, anything that begins with a $ is potentially a
substitution, a.k.a. an expansion. The parser will tr
> On Jul 7, 2021, at 10:38 PM, lisa-as...@perso.be wrote:
>
> Correct. How do others customarily use `${fdir:=$PWD}` ?
The common idiom is
: "${fdir:=$PWD}"
The ':' utility is used because it does nothing, but its arguments
are expanded as usual.
> I'd rather understand what's going on, r
> From: Kerin Millar
> To: Dennis Williamson
> Subject: Re: parameter expansion with `:` does not work
> Date: 08/07/2021 03:51:15 Europe/Paris
> Cc: lisa-as...@perso.be;
> Greg Wooledge ;
> bug-bash ;
> Chester Ramey
> On Thu, 8 Jul 2021 02:54:06 +0200 (
On Thu, 8 Jul 2021 02:54:06 +0200 (CEST)
lisa-as...@perso.be wrote:
> As I was in it, have also changed
>
>
>
> fdir=${fdir:-$PWD}
This makes sense.
>
>
>
> to
>
>
>
> fdir=${fdir:=$PWD}
Here, you are using a form of parameter expansion that intrinsically performs
variable assign
> > fdir=${fdir:=$PWD}
>
> Ack!
I know. I simply gave up. At least this will "work", even if it's
completely silly.
On Wed, Jul 7, 2021, 7:55 PM wrote:
>
>
> Things are clearer now.
>
>
>
> > Seriously, just replace the :- expansion with := and go on with your
> code.
> > It's the least intrusive change, and won't disturb your logic.
>
>
>
> I executed
>
>
>
> echo "${parameter:-word}"; echo "${parameter}"
>
From: Chet Ramey
To: lisa-as...@perso.be;
Greg Wooledge ;
bug-bash@gnu.org
Subject: Re: parameter expansion with `:` does not work
Date: 08/07/2021 00:59:52 Europe/Paris
Cc: chet.ra...@case.edu
On 7/7/21 6:53 PM, lisa-as...@perso.be wrote:
> > Yes I can see one has :- and the oth
On 7/7/21 6:53 PM, lisa-as...@perso.be wrote:
Yes I can see one has :- and the other has :=
But I also noticed : at the front, with someone saying that the command does not
exist in Gnu Bash.
No one implied that `the command' is not present in bash.
Seriously, just replace the :- expansion
> From: Greg Wooledge
> To: bug-bash@gnu.org
> Subject: Re: parameter expansion with `:` does not work
> Date: 08/07/2021 00:44:09 Europe/Paris
> On Thu, Jul 08, 2021 at 12:37:07AM +0200, lisa-as...@perso.be wrote:
> >From: Dennis Williamson
> >$ : ${foo:-bar}
>
On Thu, Jul 08, 2021 at 12:33:04AM +0200, lisa-as...@perso.be wrote:
> Talking about neater design choices, you seem to imply you have some other
> way to take user options that are composed of lists, so that one does not use
> a delimited string. What is it?
I wrote a detailed message containing
On 7/7/21 6:48 PM, lisa-as...@perso.be wrote:
I have some difficulty understanding the difference between ${parameter:-word}
and ${parameter:=word}, and when it is appropriate to use one as opposed to the
other.
Dennis Williamson succinctly summarized the differences.
${parameter:-word}
I
>From: Lawrence Velázquez
>To: lisa-as...@perso.be
>Subject: Re: parameter expansion with `:` does not work
>Date: 08/07/2021 00:39:55 Europe/Paris
>Cc: bug-bash@gnu.org
>On Wed, Jul 7, 2021, at 6:37 PM, lisa-as...@perso.be wrote:
>> So you used `:` at the beginning a
On Thu, Jul 08, 2021 at 12:37:07AM +0200, lisa-as...@perso.be wrote:
> >From: Dennis Williamson
> >$ : ${foo:-bar}
> >$ : ${foo:=bar}
> >The first form is a substitution and the second form is an assignment.
> So you used `:` at the beginning and it worked?
Are you incapable of seeing the diffe
On Wed, Jul 7, 2021, at 6:37 PM, lisa-as...@perso.be wrote:
> So you used `:` at the beginning and it worked?
Chet and Greg already spelled out your mistake. It has nothing to
do with the ':' command.
--
vq
>From: Dennis Williamson
>To: lisa-as...@perso.be
>Subject: Re: parameter expansion with `:` does not work
>Date: 08/07/2021 00:28:33 Europe/Paris
>Cc: bug-bash
>On Wed, Jul 7, 2021, 4:50 PM wrote:
>Have noticed that parameter expansion with `:` does not work
&
From: Chet Ramey
To: lisa-as...@perso.be;
bug-bash@gnu.org
Subject: Re: parameter expansion with `:` does not work
Date: 08/07/2021 00:14:36 Europe/Paris
Cc: chet.ra...@case.edu
On 7/7/21 6:12 PM, lisa-as...@perso.be wrote:
> > : ${fltype:-"texi,org"} # alternative to `flt
>From: Greg Wooledge
>To: bug-bash@gnu.org
>Subject: Re: parameter expansion with `:` does not work
>Date: 08/07/2021 00:21:33 Europe/Paris
>On Thu, Jul 08, 2021 at 12:10:27AM +0200, lisa-as...@perso.be wrote:
>> The line
>> : ${fltype:-"texi,org"}
>
On Wed, Jul 7, 2021, 4:50 PM wrote:
>
> Have noticed that parameter expansion with `:` does not work
>
>
>
> : ${fltype:-"texi,org"} # alternative to `fltype=`
>
>
$ unset foo
$ : ${foo:-bar}
$ echo "$foo"
$ : ${foo:=bar}
$ echo "$foo"
On Thu, Jul 08, 2021 at 12:10:27AM +0200, lisa-as...@perso.be wrote:
> The line
> : ${fltype:-"texi,org"}
> should be an alternative to
> fltype=${fltype:-"texi,org"}
As Chet guessed earlier, you probably meant := instead of :- .
I started typing something to that effect in my first respons
On 7/7/21 6:12 PM, lisa-as...@perso.be wrote:
> : ${fltype:-"texi,org"} # alternative to `fltype=` >
I'm not sure why you think that's an alternative. Maybe you meant
${fltype:="texi,org"}?
It is supposed to be built into bash so a new process is not created.
Perhaps not in Gnu Bash?
What
On 7/7/21 6:10 PM, lisa-as...@perso.be wrote:
The line
: ${fltype:-"texi,org"}
should be an alternative to
fltype=${fltype:-"texi,org"}
It absolutely is not.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey
From: Chet Ramey
To: lisa-as...@perso.be;
bug-bash@gnu.org
Subject: Re: parameter expansion with `:` does not work
Date: 08/07/2021 00:08:23 Europe/Paris
Cc: chet.ra...@case.edu
On 7/7/21 5:50 PM, lisa-as...@perso.be wrote:
>
> Have noticed that parameter expansion with `:` does no
>From: Greg Wooledge
>To: bug-bash@gnu.org
>Subject: Re: parameter expansion with `:` does not work
>Date: 07/07/2021 23:54:21 Europe/Paris
>On Wed, Jul 07, 2021 at 11:50:01PM +0200, lisa-as...@perso.be wrote:
>> Have noticed that parameter expansion with `:` does not w
On 7/7/21 5:50 PM, lisa-as...@perso.be wrote:
Have noticed that parameter expansion with `:` does not work
: ${fltype:-"texi,org"} # alternative to `fltype=` >
I'm not sure why you think that's an alternative. Maybe you meant
${fltype:="texi,org"}?
--
On Wed, Jul 07, 2021 at 11:50:01PM +0200, lisa-as...@perso.be wrote:
> Have noticed that parameter expansion with `:` does not work
>
> : ${fltype:-"texi,org"} # alternative to `fltype=`
What did it do? What did you *expect* it to do?
This looks like it's related to
Have noticed that parameter expansion with `:` does not work
: ${fltype:-"texi,org"} # alternative to `fltype=`
28 matches
Mail list logo