zsh-users
 help / color / mirror / code / Atom feed
* nit pick
@ 2020-12-28 14:47 Ray Andrews
  2020-12-28 16:39 ` Bart Schaefer
  2020-12-28 18:33 ` Stephane Chazelas
  0 siblings, 2 replies; 4+ messages in thread
From: Ray Andrews @ 2020-12-28 14:47 UTC (permalink / raw)
  To: Zsh Users

This is as trivial an issue as one could imagine:

    test1()
    {
         typeset -a test1=(\
         "foo"
         "bar"
         "baz")
    }

    test2()
    {
         typeset -a test1=\
        ("foo"
         "bar"
         "baz")
    }

    $ test1; test2
    test2:2: invalid mode specification

... but it seems to me that as a matter of strict logic, since the 
backslash indicates line continuation I'd expect both of the above to 
work, that is, the opening parenthesis after the equal sign should be 
seen correctly either way.  Or is there a logical reason for the difference?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: nit pick
  2020-12-28 14:47 nit pick Ray Andrews
@ 2020-12-28 16:39 ` Bart Schaefer
  2020-12-28 19:23   ` Ray Andrews
  2020-12-28 18:33 ` Stephane Chazelas
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2020-12-28 16:39 UTC (permalink / raw)
  To: Ray Andrews; +Cc: Zsh Users

On Mon, Dec 28, 2020 at 6:47 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
>     test2()
>     {
>          typeset -a test1=\
>         ("foo"
>          "bar"
>          "baz")
>     }
>
>     $ test1; test2
>     test2:2: invalid mode specification
>
> ... but it seems to me that as a matter of strict logic, since the
> backslash indicates line continuation I'd expect [...]
> the opening parenthesis after the equal sign [to] be
> seen correctly [...].

Line continuation does not remove leading spaces from the following line.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: nit pick
  2020-12-28 14:47 nit pick Ray Andrews
  2020-12-28 16:39 ` Bart Schaefer
@ 2020-12-28 18:33 ` Stephane Chazelas
  1 sibling, 0 replies; 4+ messages in thread
From: Stephane Chazelas @ 2020-12-28 18:33 UTC (permalink / raw)
  To: Ray Andrews; +Cc: Zsh Users

2020-12-28 06:47:10 -0800, Ray Andrews:
> This is as trivial an issue as one could imagine:
[...]

To paraphrase Bart,

>         typeset -a test1=(\
>         "foo"
>         "bar"
>         "baz")
>    }

That's

        typeset -a test1=(     "foo"
        "bar"
        "baz")


>         typeset -a test1=\
>        ("foo"
>         "bar"
>         "baz")
[...]

That's

         typeset -a test1=    ("foo"
         "bar"
         "baz")


The \<newline> sequence is a "line-continuation". It is
*removed*.

Note that you can also do:

typeset -a test1=(
  foo
  bar
  baz
)

-- 
Stephane


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: nit pick
  2020-12-28 16:39 ` Bart Schaefer
@ 2020-12-28 19:23   ` Ray Andrews
  0 siblings, 0 replies; 4+ messages in thread
From: Ray Andrews @ 2020-12-28 19:23 UTC (permalink / raw)
  To: zsh-users

On 2020-12-28 8:39 a.m., Bart Schaefer wrote:
>
> Line continuation does not remove leading spaces from the following line.
>
Ah!  So it really is rigorously necessary.  Yes, that's just as it 
should be, I'm sloppily ignoring the spaces and there's can't be a space.

Thanks both.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-28 19:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 14:47 nit pick Ray Andrews
2020-12-28 16:39 ` Bart Schaefer
2020-12-28 19:23   ` Ray Andrews
2020-12-28 18:33 ` Stephane Chazelas

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).