zsh-workers
 help / color / mirror / code / Atom feed
* Command expansion failure in for loops
@ 2017-06-13  1:50 Mike Brown
  2017-06-13  2:38 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Brown @ 2017-06-13  1:50 UTC (permalink / raw)
  To: zsh-workers

Hi, new to the mail list, but not new to zsh.  I've been a zsh user since,
what - the beginning of time?

I've recently brought up a new Fedora 25 Linux box, in which I installed
zsh 5.2 64 bit redhat linux gnu.  I run zsh under Solaris 5 (I started out
in SunOS way back when, moving on to Solaris and wherever I went, insisted
in zsh being installed and shipped).  I also run it under cygwin on XP (ya
I know, really old) and was running it under Fedora 14, a box that I shut
down earlier today.  It won't boot up, as I just tried.  It has a mother
board issue detecting hard drives (one of the reasons I had to replace it).

Now for the issue.  Command expansion is no longer working in for loops.
For example:

    for name in x y z
    for> do
    for> ftp_s<TAB>

It should expand to ftp_share and present ftp_spain as the other command.
Both of those commands are in my home bin directory.  Expansion of ftp_s<TAB>
works on the command line.  In the for loop, the tab key is ignored.

It worked before version 5.2.  Since the F14 box is now off, I can't check
its version, but I suspect 4.x something.  It is 4.2.1 (i386-pc-solaris2.10
on the Solaris box.

Is there something different in 5.2 that I need to know about in order to
get this working again?  I tried parsing the change history that is
online, but nothing lept out at me.

Thanks for any help with this.

MB
-- 
e-mail: vidiot@vidiot.com | vidiot@vidiot.net            /~\ The ASCII
        6082066843@email.uscc.net (140 char limit)       \ / Ribbon Campaign
Visit - URL: http://vidiot.com/                           X  Against
             http://vidiot.net/                          / \ HTML Email
"You're Sherlock Holmes, wear the damn hat!" - Watson to Sherlock
Sherlock - The Abominable Bride - 1/01/16


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

* Re: Command expansion failure in for loops
  2017-06-13  1:50 Command expansion failure in for loops Mike Brown
@ 2017-06-13  2:38 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2017-06-13  2:38 UTC (permalink / raw)
  To: Mike Brown, zsh-workers

On Jun 12,  8:50pm, Mike Brown wrote:
}
} Now for the issue.  Command expansion is no longer working in for loops.

This works if "compinit" has been run, but possibly for the wrong reason:
if there is a completion function defined, it is called so that it can
make the decision about whether to complete a word or insert a TAB (see
"usetab()" mention below).

It fails with "native" completion (compctl et al.).

}     for name in x y z
}     for> do
}     for> ftp_s<TAB>

The reason appears to have something to do with workers/36025.  When
complete-word is done on the same line as the "do" everything is fine;
it's only when on the new line after "do" that it gets confused.  At
this test --

1189            lincmd = !inredir &&
1190                ((incmdpos && !ins && !incond) ||
1191                 (oins == 2 && wordpos == 2) ||
1192                 (ins == 3 && wordpos == 1) ||
1193                 (cmdtok == NULLTOK && !incond));

-- when completing on the same line as "do", cmdtok == NULLTOK, but when
completing on the next line, cmdtok == FOR, and so lincmd becomes false
and command names are not completed (instead file names are).

I haven't tracked down why the lexical analysis changes with the extra
newline.  Probably "do" isn't being treated as a reserved word, i.e.,
lexing thinks it is "for name in x y z do;" ?

There's one additional oddity, which is that with expand-or-complete
instead of complete-word, if the line following "do" is empty then
usetab() returns true and no completion is done at all; instead a TAB
is inserted.  However, that's been that way since sometime in 4.x.

} It worked before version 5.2.

Broken for me as far back as zsh-5.0.2-dev-0 (so perhaps not directly
related to 36025 after all, but seems to be in that part of the code).


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

end of thread, other threads:[~2017-06-13  2:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-13  1:50 Command expansion failure in for loops Mike Brown
2017-06-13  2:38 ` 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).