zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Sweth Chandramouli <sweth@astaroth.nit.gwu.edu>,
	zsh-users@sunsite.auc.dk
Subject: Re: setopt and alias questions
Date: Mon, 8 Feb 1999 10:45:50 -0800	[thread overview]
Message-ID: <990208104550.ZM14297@candle.brasslantern.com> (raw)
In-Reply-To: <19990208103038.A3447@astaroth.nit.gwu.edu>

On Feb 8, 10:30am, Sweth Chandramouli wrote:
} Subject: Re: setopt and alias questions
}
} > I'm also having some other problems with it.  I had to change the "for"
} > loop expression to:
} > 
} > 	for OPT_PAIR in "${(@f)$(builtin setopt)}"; do
} > 
} > in order to get the proper split-by-lines behavior.  I'm at a loss what
} > would let it work for you without the quotes and the @ flag.
} 
} 	just as a side note, the @ flag isn't necessary

You're right.  I'm always throwing that in there needlessly; dunno why I
have it stuck in my head that any array expansion in " " needs it.

} > } aside from global aliases, is there any reason
} > } to not put all of my aliases into equivalent functions?
} > 
} > Probably not.  (Functions aren't exported either, though.)
} 	no, but they can be dropped in a .zfunc folder, so that
} only an autoload loop needs to be put in .zshrc for all shells to
} have access to them. 

You don't even need a loop.

	autoload $^fpath/*(.:t)

} > Hrm.  Zsh actually goes out of its way to make "." in $PATH work even if
} > the command has previously been hashed to somewhere (later) in the path.
} 	does it do this for all tokens in $path, or just "."?  the former
} makes sense; i don't think i would be very comfortable with the latter

It only does it for ".".  The way it works is that the command hash table
actually contains a pointer into the $path array.  When you execute "ls"
(for example), zsh fetches its hash entry (creating it if it doesn't find
it), finds in the hash entry a pointer to the string "/bin" within $path,
and then searches for that pointer in the array.  For each path element
that does not match the pointer, it checks if that element is ".".  If it
encounters "." before it finds itself back at the pointer to "/bin", it
executes ./ls, otherwise it executes /bin/ls.

(Now that I think about it, I'm surprised that it doesn't do this same
test for ".." or in fact for any path element beginning with "./" or
"../".  Not that I can think of any reason why somebody would put ".."
in their path.  Anyway ...)

Any time you change $PATH or $path, zsh throws out the command hash
table and (incrementally) rebuilds it, so the pointers into the array
are valid for purposes of this search.  And none of this happens for
commands that already have a full path.

} 	-- sweth, who secretly kind of likes the idea of an
} obfuscated zsh contest.

Can you figure out what this is doing?  (Not terribly obfuscated, I admit.)

	ov=${(L)${${ov/on/OFF}/off/on}}

BTW, that works only in 3.1.5-pws-something.  Exercise for the reader:
What two characters, inserted twice, give the same effect in 3.0.5?

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


  reply	other threads:[~1999-02-08 18:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-08  0:37 Sweth Chandramouli
1999-02-08  1:59 ` Bart Schaefer
1999-02-08  4:52   ` Sweth Chandramouli
1999-02-08  7:33     ` Bart Schaefer
1999-02-08 15:30       ` Sweth Chandramouli
1999-02-08 18:45         ` Bart Schaefer [this message]
1999-02-08 19:15           ` Sweth Chandramouli
1999-02-08 19:44             ` Bart Schaefer
1999-02-08 19:59               ` Sweth Chandramouli
1999-02-08 20:55                 ` Bart Schaefer
1999-02-12 19:34                   ` Sweth Chandramouli
1999-02-12 20:13                     ` Bart Schaefer
1999-02-08 19:46             ` Sweth Chandramouli
1999-02-08 20:30               ` Bart Schaefer
1999-02-09  8:40                 ` Phil Pennock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=990208104550.ZM14297@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=sweth@astaroth.nit.gwu.edu \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).