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

Re: Compctl fixes & a query

>A.Main@xxxxxxxxxxxxxxxxx wrote:
>> On a separate matter, does anyone ever use the numerical equals
>> expansion?
>Yes, but tildes would be more in keeping with other syntax for
>directories (~+ and ~- being sort of tied to the directory stack
>anyway): also, there's no good reason for associating this behaviour
>with the noequals option as is currently the case.  If implemented
>properly it would even allow trailing characters after a number to be
>a separate directory name, since only a / or end of word would be a
>separator, unlike the present case with =<num>.

That's the basic idea.  ~whatever is a directory, but =whatever is a
file.  Also, there's no problem with ksh kompatibility, as ksh doesn't
do this (though it does have ~+ and ~-).

>                                                 At the moment, it
>doesn't look like ~<num> works at all, i.e. even with `hash -d 1 dir',
>so there aren't compatibility problems there (in fact there's a bug,
>since the directory will appear as ~1 in the stack).

Yes.  The routine that looks up a name for a directory uses whatever's
in the table, regardless of what characters are in the name (including
/, *, etc.).  The filename substitution routine will ignore a name that
starts with any non-alphabetic character or contains anything other
than alphanumerics, - or _.  It also treats ~/whatever specially, not
looking it up in the table.  Similarly ~+ and ~-, which don't go into
the table (otherwise your cwd would always appear as ~+ in the prompt,
except when you're in / or ~).

I'd like to fix the above consistency problems.  This requires a couple
of changes in behaviour:

o hash mustn't accept names that include /, or begin with + or - (note
  that no such name would be a legal parameter name).  This, in respect
  of /, would apply to command hashing too, but the PATH_DIRS option
  makes it make sense in that case.

o As an alternative to the above, the routine that looks up a name for
  a given directory must ignore names starting with + and -, or
  containing a /.  I'm not sure which of these two controls should be

o The name lookup routine that looks up the meaning of a ~ expression
  must not treat ~/ specially, but must look it up in the normal way.
  It may only treat names starting with + and - specially.

I think that, in the interests of consistency and name space
preservation, it would be a good idea to use ~+n rather than ~n, as
this reduces the number of characters that are treated specially.  ~+n
and ~-n can then be interpreted however pushd interprets +n and -n,
depending on whether PUSHD_MINUS is set or not.  What do people think
of this?

>We could possibly kludge =<num> followed by a slash or space where
><num> is not a command for the time being, but maybe going straight to
>tildes is the right thing.

It's *much* easier to change it straight to ~.

>Now I've got my working directory called ~1, which I can't alter...

hash -dr; rehash -d; hash -d 1 /; # there's always more than one way in Zsh.


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