[Top][All Lists]

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

Re: parameter expansion with `:` does not work

From: Greg Wooledge
Subject: Re: parameter expansion with `:` does not work
Date: Wed, 7 Jul 2021 18:21:33 -0400

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.

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]