zsh-workers
 help / color / mirror / code / Atom feed
From: "Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru>
To: "Zsh hackers list" <zsh-workers@sunsite.dk>
Subject: RE: Export problem
Date: Wed, 6 Jun 2001 18:41:36 +0400	[thread overview]
Message-ID: <002901c0ee96$c9e38490$21c9ca95@mow.siemens.ru> (raw)
In-Reply-To: <20010606094857.A23921@dman.com>


>
> > - in ${x:=word} word is *never* splitted irrespectively of
> where it appears
> > and if it is quoted
>
> Where is that stated?
>

Nowhere. You misunderstand the basic concept of field splitting in sh. I
suspect, it is a result of incorrect implementation of splitting in zsh.

Field Splitting is the step in processing of command line. It happens
*after* parameter substitution. It means, that ``word'' in ${x:=word} is
never splitted - the *result* of this substitution as a whole may possibly
be splitted.

> > - x=word is not splitted (should I add "never"?)
>
> Where is that stated?
> Your quote of SUS (which is lifted from POSIX) said
> that each variable assignment undergoes expansion
> in step 4, including parameter expansion and command
> substitution.  In addition, the bit about Field Splitting
> says that "the shell shall scan the results of expansions
> and substitutions that did not occur in double-quotes
> for field splitting and multiple fields can result."
> It then goes on to talk about IFS and how splitting
> is to occur.  I also don't see any exceptions or
> proscriptions against splitting when variable assignment
> is involved.
>

It does not say "the shell scans the result of *every* expansion ...".
Please, understand - splitting in sh does not happen as part of
variable/command substitution. It happens after these substitutions have
been done. The above simply means that in ``IFS=:; ls a:b${foo}'' the a:b
will *not* be splitted even though IFS is set to ``:''. But ${foo} possibly
will. That is also correctly implemeted by zsh and bash.

> > - in export x=word the whole `x=word' is field splitted unless quoted.
>
> That seems fairly straight-forward, but I don't understand the
> intended effect.  The output of field splitting is "fields."
> The input is whatever results from the expansion or substitution
> of "words."  Does POSIX define these things?
>

Yes. Please, look in grammar for definition of WORD, look here
<http://www.opengroup.org/onlinepubs/007908799/xcu/chap2.html#tag_001_006>
for precise definition how expansions are performed and look in my previous
mail for definition how fields are used (first field becomes command name,
subsequent fields become arguments).

> If `date +%z%f` expanded to "-0400; rm -rf .", what should
>
> export THIS=`date +%z%f` do?
>
> a) export THIS with the value "-0400; rm -rf ."
> b) export THIS with the value "-0400; rm -rf ." as an array of 4 words?
>    POSIX doesn't seem to acknowledge the concept of arrays in the Shell
>    Command Language.
> c) export THIS with the value "-0400;" and try to export parameters
>    named "rm", "-rf", and "."?

One answer for all - it should execute command ``export'' with parameters:

THIS=-0400;
rm
-rf
.

What the command ``export'' does with these parameters - it is up to this
command.

> d) retokenize the line and treat it as a sequential list of two commands?
>

Oh, no! Please :-)

-andrej


  reply	other threads:[~2001-06-06 14:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-04 18:30 a normal guy
2001-06-04 18:42 ` Geoff Wing
2001-06-05  5:18   ` Andrej Borsenkow
2001-06-05  9:35     ` Peter Stephenson
2001-06-06  7:51       ` Clint Adams
2001-06-06  8:18         ` Andrej Borsenkow
2001-06-06 13:48           ` Clint Adams
2001-06-06 14:41             ` Andrej Borsenkow [this message]
2001-06-06 15:23               ` Clint Adams
2001-06-06  8:27       ` Andrej Borsenkow
2001-06-05  9:39     ` Peter Stephenson
2001-06-05 10:16       ` Andrej Borsenkow
     [not found] <1010605064402.ZM4270@candle.brasslantern.com>
2001-06-05 15:52 ` a normal guy
2001-06-06  5:56   ` Andrej Borsenkow
2001-06-06 10:06     ` Bart Schaefer
2001-06-11 18:24 HP-UX 11.00 tgetenv dilemma Andrej Borsenkow
2001-06-11 22:05 ` Export problem a normal guy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='002901c0ee96$c9e38490$21c9ca95@mow.siemens.ru' \
    --to=andrej.borsenkow@mow.siemens.ru \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).