zsh-users
 help / color / mirror / 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

zsh-users

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-users zsh-users/ http://inbox.vuxu.org/zsh-users \
		zsh-users@zsh.org
	public-inbox-index zsh-users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git