* Two esoteric zsh questions
@ 2000-09-05 20:21 Jerry Peek
2000-09-08 20:19 ` Zefram
2000-09-08 22:25 ` Bart Schaefer
0 siblings, 2 replies; 3+ messages in thread
From: Jerry Peek @ 2000-09-05 20:21 UTC (permalink / raw)
To: zsh-users
(Is *any* zsh question esoteric? Or are *all* zsh questions? ;-)
Here's a question that might be a bug, then a follow-up "how to".
I'm using 3.0.7 on Linux (Red Hat 6.2) right now.
----------------------------------------------------------------------
1) Can anyone explain the difference in the following two cases? The
first sets a shell variable; the second sets an environment variable.
In the second, I have to quote the `who`:
% whoson=`who`
%
% export WHOSON=`who`
zsh: not an identifier: 06:56
% export WHOSON="`who`"
%
(The first line of the "who" output ends with 06:56.)
I looked through the FAQ and scanned through a change list... but
didn't spot changes in more recent versions, so I'm asking the list.
Is the difference a bug, side effect, or feature?
----------------------------------------------------------------------
2) I wanted to compare the values of $whoson and $WHOSON. I couldn't
think of a way to use two <<< operators, so I tried this kludge:
% diff - <(echo $WHOSON) <<<$whoson
%
Does anyone know a cleaner way to do that?
[BTW, this next mess wasn't as simple but it worked fine too:
% diff - <(cat <<<$WHOSON) <<<$whoson
zsh is amazing...]
----------------------------------------------------------------------
Thanks!
--Jerry Peek, jpeek@jpeek.com
http://www.jpeek.com/
PS: I mentioned last spring that the third edition of Unix Power Tools
will cover zsh -- and asked if the new shell would be ready by August
so we could put it on the book's CD-ROM. FYI, due to some scheduling
problems, I'm still working on the book; the target date is early 2001.)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Two esoteric zsh questions
2000-09-05 20:21 Two esoteric zsh questions Jerry Peek
@ 2000-09-08 20:19 ` Zefram
2000-09-08 22:25 ` Bart Schaefer
1 sibling, 0 replies; 3+ messages in thread
From: Zefram @ 2000-09-08 20:19 UTC (permalink / raw)
To: Jerry Peek; +Cc: zsh-users
Jerry Peek wrote:
>1) Can anyone explain the difference in the following two cases? The
>first sets a shell variable; the second sets an environment variable.
>In the second, I have to quote the `who`:
>
> % whoson=`who`
> % export WHOSON=`who`
>
>I looked through the FAQ and scanned through a change list... but
>didn't spot changes in more recent versions, so I'm asking the list.
>Is the difference a bug, side effect, or feature?
Side effect of the way `export' is defined. These two commands use
completely different bits of shell grammar. The first is a variable
assignment, in which field splitting is not performed -- everything
in the word on the RHS of the = is assigned to the variable named.
The second is a simple command; the first word is `export' and the
second is `WHOSON=`who`'. In the expansion of that second word, the
backquoted section is subjected to field splitting (I think `` and
$() are the only places where zsh does field splitting by default),
which results in a simple command with more than just the two words.
The `export' command looks at each argument in turn and tries to make
an assignment out of it; its second and subsequent arguments in this
case are part of the output of who.
-zefram
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Two esoteric zsh questions
2000-09-05 20:21 Two esoteric zsh questions Jerry Peek
2000-09-08 20:19 ` Zefram
@ 2000-09-08 22:25 ` Bart Schaefer
1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-09-08 22:25 UTC (permalink / raw)
To: Jerry Peek, zsh-users
On Sep 5, 1:21pm, Jerry Peek wrote:
>
> (Is *any* zsh question esoteric? Or are *all* zsh questions? ;-)
Both.
> 1) Can anyone explain the difference in the following two cases? The
> first sets a shell variable; the second sets an environment variable.
Zefram answered this.
> 2) I wanted to compare the values of $whoson and $WHOSON.
You mean you wanted to see the differences, not just know whether there
are differences? When I hear "compare the values" I think of
[[ $whoson == $WHOSON ]]
> I couldn't think of a way to use two <<< operators
Right; if you did so, multios would concatenate the two inputs.
> % diff - <(echo $WHOSON) <<<$whoson
> %
>
> Does anyone know a cleaner way to do that?
Aside from using "print -r --" in place of "echo", so that backslashes or
leading hyphens in $WHOSON won't cause problems, the only thing that comes
to mind is
diff <(<<<$whoson) <(<<<$WHOSON)
which is really mostly same as
> % diff - <(cat <<<$WHOSON) <<<$whoson
except that zsh implements the "cat" internally, and you can give the args
in the same order that they'll appear in the diff output, which is slightly
more understandable.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-09-08 22:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-05 20:21 Two esoteric zsh questions Jerry Peek
2000-09-08 20:19 ` Zefram
2000-09-08 22:25 ` Bart Schaefer
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).