[Top][All Lists]

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

parameter expansion with `:` does not work

From: lisa-asket
Subject: parameter expansion with `:` does not work
Date: Thu, 8 Jul 2021 00:10:27 +0200 (CEST)

>From: Greg Wooledge <greg@wooledge.org>
>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-asket@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?

The line 

: ${fltype:-"texi,org"}  

should be an alternative to 


If you have a lot of variables to initialize to defaults and they have long 

the `:` approach would be prefereable, both for typing and for reading.

When I try it, fltype is not being set.

>This looks like it's related to your ongoing project to make your
>simple script as complex as possible. As such, it appears you're
>digging into the bowels of the Bourne shell and trying to dig up
>every obscure piece of syntax you can find, so that you can use
>them all, to be completely sure you can't possibly read the script
>a week from now.

Certainly part of all that.  I am not against complexity myself. I simply

want my script to work as I wish, even though I possibly won't remember

all the implementation details.  Am quite sure that a man of your intellect 

won't have a problem figuring things out.

>I advise you to stop doing this.

This is where we disagree

>In this particular instance, you're assigning a LIST of two values
>to a STRING variable, using a comma as a delimiter between them.
>Presumably you're going to split this list apart later on.

>Wouldn't it be a whole lot simpler to store the list in an ARRAY

>variable in the first place, and avoid the need to split it?

I do that later, because I have a user set argument using delimiter between

file types.  

reply via email to

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