Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: compinit causes completion to fail?

On Apr 29, 2012, at 8:26 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:

On Apr 29,  2:57am, TJ Luoma wrote:
} IFS='
} '
} is what was causing the problem.

Could you say a bit more about exactly how this caused a problem?  In
normal circumstances the value of IFS shouldn't affect parsing of
scripts etc., it should only affect "read" and parameter substitution.
So I'm puzzled as to how you got the command-not-found symptom.

Well, I don't know exactly either.  Here's what I did:

I had split my zshenv and zshrc files into several files. The
~/.zshenv was skeleton which sourced the other files as appropriate
(aside: it does seem faster this way).

But when I did that, completion broke with that "_normal not found" error.

So I removed the ~/.zshenv file, and completion worked (with no customizations).

{Note: by completion I mean just the basics: command completion and
'cd' completion.}

Then I started sourcing files one at a time and testing completion
(deleting ~/.zcompdump between each test by telling ~/.zlogout to
delete the file and exiting the shell after each one).

Completion broke ONLY when I added the explicit call to 'autoload'
completion stuff, which seemed completely nonsensical.

So I started all over again with a completely empty .zshenv EXCEPT for
the calls the source the various files.  I thought it might have to do
with the *order* something was being loaded (bindkeys before setopts,
etc) so I organized my .zshenv to source the files in a way that I
thought made sense (i.e. environmental variables first, setting my
prompt last, etc).

I left everything commented out, and started un-commenting things one
at a time, from the bottom-up (I don't know why I chose the bottom-up,
it seemed like a good idea at the time).

So it went like this:

* uncomment last file-to-source from within .zshenv
* start a new shell
* test to see if command and 'cd' completion worked
* exit shell (deleting ~/.zcompdump)

* uncomment last-1 file-to-source from within .zshenv
* start a new shell
* test to see if command and 'cd' completion worked
* exit shell (deleting ~/.zcompdump)

and so on.

When I got to the top of the .zshenv file, I realized completion STILL
worked. So I looked at that .zshenv compared to the one I had used
earlier (Thank you, Dropbox versioning!)

The only difference was that the old .zshenv was that I had put in a
few settings that I thought were important at the top of the .zshenv,
including the IFS line.

When I had a giant .zshenv/.zshrc file, the IFS line was after the
completion stuff, but when I had broken it up into pieces, I thought
that I should put the IFS near the top because it seemed like
otherwise I might get inconsistent results. (Not sure if that would
have been a problem, but that was my thinking.)

I started adding those "odds and ends" back into the top of my
.zshenv, and then did the same logout/login.

Everything worked fine UNTIL I put the IFS line in at the top of the
.zshenv. When I did that, completion broke. When I took it out,
completion worked.

Truthfully, I forgot why I had the IFS line in there, so I had to go
back to Google (which wasn't easy) and realized that I had done that
for when I was running a command and capturing the output into an
array, and the output of the command might have newlines in it.

I went *back* to Google and looked for an alternative, assuming that
there was a better way.

That's when I learned about defining IFS at the front of the array, like this:

IFS=$'\n' array_of_lines=($(my_command))



(both of those examples gleaned from

Then I went to the bash-to-zsh book and learned more about it, or tried to.

I think that's about all I can remember.

No, I don't think it makes sense either.


Messages sorted by: Reverse Date, Date, Thread, Author