* Determining whether a user name is valid
@ 1996-07-25 6:44 Bart Schaefer
0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 1996-07-25 6:44 UTC (permalink / raw)
To: zsh-users
I share my .zsh{env,rc} across several machines. On some, but not all, of
these machines, there exist certain files in other users' home directories;
files that, when they exist, I would like to reference from my .zsh{env,rc}.
*If* any of the users in question has an account on a machine, the file is
always found in the same place relative to his home directory. However,
the home directories themselves are not always in the same places. Thus I
would like to refer to these files as (e.g.) ~foo/fileX and ~bar/fileY.
Unfortunately, I normally use cshnullglob, which means that a reference to
the named directory ~foo is an error when foo is *not* a known user. So I
have to find out if foo is a user before I can reference ~foo. (There is
no equivalent of nullglob for file expansion, though nonomatch applies to
both filename expansion and filename generation.)
So, there are a couple of workarounds I can think of:
[[ -n "$(unsetopt cshnullglob; setopt nonomatch;
[[ -d ~foo ]] && echo ok)" ]]
Or:
[[ -n "$(hash -df ; hash -dm foo)" ]]
The latter is of course very poor when there are a large number of users.
Does anyone know a better way?
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.nbn.com/people/lantern
New male in /home/schaefer:
>N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1996-07-25 6:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-25 6:44 Determining whether a user name is valid 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).