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

Re: bug with chpwd/allexport (plus expansion/substitution remarks)



On Jul 17,  3:27pm, Dominik Vogt wrote:
} Subject: Re: bug with chpwd/allexport
}
} > >         The problem is, that is you have the ALLEXPORT and the
} > >AUTONAMEDIRS option set and use a variable in your chpwd function
} > >(e.g. to build a string to print it on the windows title bar),
} > >the variable is immediately put into the hashtable for named
} > >directories.
} > 
} > That's correct behaviour.

This doesn't actually have anything to do with ALLEXPORT, does it?  As
soon as you set AUTONAMEDIRS, it behaves like this.

On Jul 17,  2:42pm, Zefram wrote:
} Subject: Re: bug with chpwd/allexport
}
} Dominik Vogt wrote:
} >                        BTW if the second workaround you suggest works,
} >then it is a bug. The manpage states clearly, that a local variable is
} >still exported if the ALLEXPORT option is set and the variable was
} >prviously unset.
} 
} But with `local', the variable disappears at the end of the function,

That also doesn't affect whether the name is added to the named directory
hash table.  Unsetting the variable doesn't unhash the name; making it a
local has no effect on this problem whatsoever.

On Jul 17,  5:42pm, Dominik Vogt wrote:
} Subject: Re: bug with chpwd/allexport
}
} > You seem to be confusing the concepts of `existing outside the shell
} > function' and `exported' (visible to programs invoked from the shell).
} > The two are mostly, though not entirely, independent of each other.
} 
} No, I just wasn't reading the manpage carefully. Perhaps the manpage
} should be written in a way that a 'normal' user can understand
} implications like this after reading in once.

This would be ideal, but is nearly impossible to achieve.  We can try to
catch obvious cases, and sometimes add doc for particular instances we
discover (like this one); but there are too many options and too many ways
they interact to describe all the possible combinations in the manual.

} There are some other
} 'mysteries' of zsh. For example the exact order in which quoting
} and substitution are done. For example the manpage doesn't state
} which substitutions/expansions recognize which kinds of quoting.

The info files do explain this, though you are again correct that there's
no single place that enumerates all the steps.  The section on "Quoting"
should probably be moved to appear earlier in the "Shell Grammar" section,
or even outside it (perhaps a new section on "Lexical Conventions" should
be added, to explain how "words" and "tokens" are identified).

The short answer to "which substitutions/expansions recognize which kinds
of quoting" is that -none- of them recognize quoting.  Quoting is a lexical
convention applied at the time the input is read; by the time expansions
occur, everything is already broken into words/tokens.  Did you mean "what
quotings permit or prevent which substitutions/expansions?"  The "Quoting"
section is deficient in failing to mention that history expansion occurs
inside double quotes but not inside single quotes, but is otherwise OK.

The "Expansion" section is potentially misleading, because it discusses
removal of the unquoted quotes from the input; in fact I can't think of a
case where it makes a difference when those quotes are removed, because
the quoting itself has already happened.  E.g.:

	print -l x{"a,b,c"}x

The quotes aren't removed until after brace expansion (according to the
info doc) but the commas are already quoted by the time brace expansion is
attempted.  (I have no idea what effect SH_FILE_EXPANSION has on when the
quotes are removed, or whether it matters.)

Or perhaps you mean "what quotings are recognized in the replacement text
that results from which substitutions/expansions?"  Again, the answer is
that none are.  Expansions (except alias expansion, but including history,
now that the old lexical history options are gone) are already tokenized
when replaced [*] and substitutions are subject to word splitting at IFS
unless double-quoted.

[*] Is that the only thing that distinguishes expansion from substitution?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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