help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Awkward behavior of empty arrays


From: Andy Chu
Subject: Re: [Help-bash] Awkward behavior of empty arrays
Date: Thu, 31 Aug 2017 09:32:47 -0700

On Thu, Aug 31, 2017 at 9:23 AM, DJ Mills <address@hidden> wrote:

> Use case for "$*" (or similarly "${a[*]}"):
>
> join() {
>   local IFS=$1
>   shift
>   printf '%s\n' "$*"
> }
>
> arr=(foo bar baz)
> join '+' "address@hidden"
>
> With a change in IFS, the construct becomes rather useful
>

Yes that's true, those semantics can't be expressed with 
joined="address@hidden".
I guess I add an operation like "ifsjoin" to my restricted set of rules.

(Part of the reason I'm thinking about these rules is as a style guide; the
other reason is to enable automatic and correct OSH to Oil translation,
e.g. http://www.oilshell.org/blog/2017/02/05.html .  As mentioned Oil has
more Python-like arrays, where the type is carried along with the value and
not the variable/location.)

thanks,
Andy


reply via email to

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