[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:33:04 +0200 (CEST)

>From: Greg Wooledge <greg@wooledge.org>
>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-asket@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 response, but then
>I noticed the payload you were "assigning" (though you messed up the
>syntax) and decided to try to teach you to fish, rather than tossing
>you the decrepit, smelly old fish you had dropped in the dirt.

>You are using horrible syntax to do the *wrong thing*.

>Lists should be stored in indexed array variables, not in strings with
>silly delimiters.

>Initialize an array variable holding the default list of extensions at
>the beginning of your program. Then, in your option-processing code,
>if the user supplies their own delimited list of extensions, split it
>apart and use the resulting list to overwrite the array variable.

>That's it. No need for 40-year-old crappy syntax. No need to store
>your default list as a delimited string and then spend system resources
>splitting it apart. You only need to expend those resources if the user
>supplies a delimited list, and the user only needs to do that because of
>the crappy design choices you've made.

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?

>But since the user is you, if that's how you *really* want the program
>to work, then so be it. Just don't make it even worse than it needs to

reply via email to

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