[Top][All Lists]

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

Re: Splitting variable into two numbers

From: Greg Wooledge
Subject: Re: Splitting variable into two numbers
Date: Tue, 20 Jul 2021 16:14:31 -0400

On Tue, Jul 20, 2021 at 10:07:28PM +0200, wrote:
> >That's what you're using the outputs for. But where does the *input*
> >come from? Why is it in this weird format with curly braces?
> Just a user argument to a function.  What is a compound way to pass 
> multiple values that are not considered weird ?

The obvious way would be to pass them as two separate arguments:

myfunc 13 21

If for some reason you feel you *must* pass them as a single argument,
you can simply pass them without the curly braces:

myfunc 13,21

Why would you go out of your way to type those curly braces when they
aren't required?

> At least the user would not be required
> to escape them on quote the value.

But they *are*!  The curly braces invoke bash's brace expansion feature.

unicorn:~$ echo {13,21}
13 21

So not only does your user (who I presume is *you*) have to type these
curly braces, they also have to quote them to prevent brace expansion
from happening.

It's a whole lot of extra work, both for the script writer and for the
user, when simpler alternatives would do the job better.

(And *this* is why we ask WAYTTD.)

reply via email to

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