* Null tilde expansions?
@ 1998-10-06 18:16 Greg Badros
1998-10-07 1:13 ` Sweth Chandramouli
1998-10-07 3:54 ` Bart Schaefer
0 siblings, 2 replies; 11+ messages in thread
From: Greg Badros @ 1998-10-06 18:16 UTC (permalink / raw)
To: zsh-users
Is there any way to make ~notauser not cause an error (similar to the
null globbing option)?
I'd like this to give me the home directories of all the users in group oo_gang
users=(`ypcat group | awk -F: '/^oo_gang\>/ { printf $4 }' | tr , ' '`)
dirs=~$^users
without first having to eliminate users from $users which no longer
exist (our sysadmins aren't good about eliminating users from groups
when the remove the user account).
Thanks,
Greg
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-06 18:16 Null tilde expansions? Greg Badros
@ 1998-10-07 1:13 ` Sweth Chandramouli
1998-10-07 3:54 ` Bart Schaefer
1 sibling, 0 replies; 11+ messages in thread
From: Sweth Chandramouli @ 1998-10-07 1:13 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 751 bytes --]
On Tue, Oct 06, 1998 at 11:16:28AM -0700, Greg Badros wrote:
> exist (our sysadmins aren't good about eliminating users from groups
> when the remove the user account).
don't know about how to do what you want in zsh, but here's a
quick perl script i whipped up a week ago to do what your sysadmins
aren't doing. set $groupfile_out to something else at first, to test,
since i don't want to be responsible for anything happening to your system.
(this assumes you can either run this script as root or convince your
admins to, of course...)
-- sweth.
--
Sweth Chandramouli
IS Coordinator, The George Washington University
<sweth@gwu.edu> / (202) 994 - 8521 (V) / (202) 994 - 0458 (F)
<a href="http://astaroth.nit.gwu.edu/~sweth/disc.html">*</a>
[-- Attachment #2: Perl Script To Remove Non-Valid Users From /etc/group --]
[-- Type: application/x-perl, Size: 1463 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-06 18:16 Null tilde expansions? Greg Badros
1998-10-07 1:13 ` Sweth Chandramouli
@ 1998-10-07 3:54 ` Bart Schaefer
1998-10-07 15:00 ` Greg Badros
1 sibling, 1 reply; 11+ messages in thread
From: Bart Schaefer @ 1998-10-07 3:54 UTC (permalink / raw)
To: Greg Badros, zsh-users
On Oct 6, 11:16am, Greg Badros wrote:
} Subject: Null tilde expansions?
}
} Is there any way to make ~notauser not cause an error (similar to the
} null globbing option)?
unsetopt badpattern
users=(`ypcat group | awk -F: '/^oo_gang\>/ { printf $4 }' | tr , ' '`)
dirs=(~$^users)
dirs=(${(M)dirs:#~)
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-07 3:54 ` Bart Schaefer
@ 1998-10-07 15:00 ` Greg Badros
1998-10-07 15:11 ` Peter Stephenson
1998-10-07 15:26 ` Bart Schaefer
0 siblings, 2 replies; 11+ messages in thread
From: Greg Badros @ 1998-10-07 15:00 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh-users
"Bart Schaefer" <schaefer@brasslantern.com> writes:
> On Oct 6, 11:16am, Greg Badros wrote:
> } Subject: Null tilde expansions?
> }
> } Is there any way to make ~notauser not cause an error (similar to the
> } null globbing option)?
>
> unsetopt badpattern
> users=(`ypcat group | awk -F: '/^oo_gang\>/ { printf $4 }' | tr , ' '`)
> dirs=(~$^users)
> dirs=(${(M)dirs:#~)
This doesn't work for me with Zsh 3.1.4 (few if any patches) or Zsh 3.0.5:
% unsetopt badpattern
% echo ~notauser
zsh: no such user or named directory: notauser
The badpattern option does look like the right thing, but perhaps it's broken?
Thanks for the response...
Greg
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-07 15:00 ` Greg Badros
@ 1998-10-07 15:11 ` Peter Stephenson
1998-10-07 15:26 ` Bart Schaefer
1 sibling, 0 replies; 11+ messages in thread
From: Peter Stephenson @ 1998-10-07 15:11 UTC (permalink / raw)
To: Greg Badros, zsh-users
Greg Badros wrote:
> "Bart Schaefer" <schaefer@brasslantern.com> writes:
> % unsetopt badpattern
> % echo ~notauser
> zsh: no such user or named directory: notauser
>
> The badpattern option does look like the right thing, but perhaps
> it's broken?
I think the appropriate option is 'nomatch'. (Sounds OK to me, it's a
match that's failing rather than a pattern that's been typed wrongly.)
% setopt nomatch
% echo ~nouser
zsh: no such user or named directory: nouser
% setopt nonomatch
% echo ~nouser
~nouser
%
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarotti 2, 56100 Pisa, Italy
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-07 15:00 ` Greg Badros
1998-10-07 15:11 ` Peter Stephenson
@ 1998-10-07 15:26 ` Bart Schaefer
1998-10-07 15:41 ` Greg Badros
1 sibling, 1 reply; 11+ messages in thread
From: Bart Schaefer @ 1998-10-07 15:26 UTC (permalink / raw)
To: Greg Badros; +Cc: zsh-users
On Oct 7, 8:00am, Greg Badros wrote:
} Subject: Re: Null tilde expansions?
}
} "Bart Schaefer" <schaefer@brasslantern.com> writes:
}
} > On Oct 6, 11:16am, Greg Badros wrote:
} > } Subject: Null tilde expansions?
} > }
} > } Is there any way to make ~notauser not cause an error (similar to the
} > } null globbing option)?
} >
} > unsetopt badpattern
}
} This doesn't work for me with Zsh 3.1.4 (few if any patches) or Zsh 3.0.5:
In the words of Geoff Wing: I hate it when I stuff up a post.
unsetopt badpattern nomatch
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-07 15:26 ` Bart Schaefer
@ 1998-10-07 15:41 ` Greg Badros
1998-10-07 16:47 ` Bart Schaefer
0 siblings, 1 reply; 11+ messages in thread
From: Greg Badros @ 1998-10-07 15:41 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh-users
"Bart Schaefer" <schaefer@brasslantern.com> writes:
> On Oct 7, 8:00am, Greg Badros wrote:
> } Subject: Re: Null tilde expansions?
> }
> } "Bart Schaefer" <schaefer@brasslantern.com> writes:
> }
> } > On Oct 6, 11:16am, Greg Badros wrote:
> } > } Subject: Null tilde expansions?
> } > }
> } > } Is there any way to make ~notauser not cause an error (similar to the
> } > } null globbing option)?
> } >
> } > unsetopt badpattern
> }
> } This doesn't work for me with Zsh 3.1.4 (few if any patches) or Zsh 3.0.5:
>
> In the words of Geoff Wing: I hate it when I stuff up a post.
>
> unsetopt badpattern nomatch
Thanks. There were also some problems with the removing of ~notauser
words that you suggested:
> dirs=(${(M)dirs:#~)
Besides the obvious typo of a closing paren for a closing brace, there
are three problems:
1) I want the (R)est, not the match, right?
2) The ~ needs to be escaped, otherwise it'll get expanded. So what
actually works for me in Zsh-3.1.4 and Zsh-3.0.x is:
3) The pattern after the # needs to match the whole word, so it needs a
trailing *.
echo ${(R)dirs:#\~*} # words that do not start with ~
#or
echo ${(M)dirs:#/*} # words that start with /
Thanks again for your pointers and suggestions. (And thanks to Peter
Stephenson as well!)
Greg
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-07 15:41 ` Greg Badros
@ 1998-10-07 16:47 ` Bart Schaefer
1998-10-07 17:50 ` Greg Badros
0 siblings, 1 reply; 11+ messages in thread
From: Bart Schaefer @ 1998-10-07 16:47 UTC (permalink / raw)
To: Greg Badros, zsh-users
On Oct 7, 5:11pm, Peter Stephenson wrote:
} Subject: Re: Null tilde expansions?
}
} I think the appropriate option is 'nomatch'. (Sounds OK to me, it's a
} match that's failing rather than a pattern that's been typed wrongly.)
I first tried it with just no_nomatch, and got an error. However, now
that I fool with it again, I must have mistyped something else, because
it is indeed only no_nomatch that's required.
On Oct 7, 8:41am, Greg Badros wrote:
} Subject: Re: Null tilde expansions?
}
} > dirs=(${(M)dirs:#~)
}
} Besides the obvious typo of a closing paren for a closing brace, there
} are three problems:
}
} 1) I want the (R)est, not the match, right?
} 2) The ~ needs to be escaped, otherwise it'll get expanded.
} 3) The pattern after the # needs to match the whole word, so it needs a
} trailing *.
Bleah. This is what I get for testing stuff on a machine where the only
home directory is my own, so the expansion of the only valid username
"accidentally" matches the expansion of ~.
Yes, you're right. Or just ${dirs##~*}, in which the ~ is not expanded
in the first place.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-07 16:47 ` Bart Schaefer
@ 1998-10-07 17:50 ` Greg Badros
1998-10-07 18:36 ` Bart Schaefer
0 siblings, 1 reply; 11+ messages in thread
From: Greg Badros @ 1998-10-07 17:50 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh-users
"Bart Schaefer" <schaefer@brasslantern.com> writes:
> On Oct 7, 8:41am, Greg Badros wrote:
> } Subject: Re: Null tilde expansions?
> }
> } > dirs=(${(M)dirs:#~)
> }
> } Besides the obvious typo of a closing paren for a closing brace, there
> } are three problems:
> }
> } 1) I want the (R)est, not the match, right?
> } 2) The ~ needs to be escaped, otherwise it'll get expanded.
> } 3) The pattern after the # needs to match the whole word, so it needs a
> } trailing *.
>
> Bleah. This is what I get for testing stuff on a machine where the only
> home directory is my own, so the expansion of the only valid username
> "accidentally" matches the expansion of ~.
>
> Yes, you're right. Or just ${dirs##~*}, in which the ~ is not expanded
> in the first place.
Why does the ~ not get expanded? This doesn't work in 3.1.4 or 3.0.x
for me. I need to escape the ~ with a backslash here, too.
Greg
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-07 17:50 ` Greg Badros
@ 1998-10-07 18:36 ` Bart Schaefer
1998-10-08 7:29 ` Peter Stephenson
0 siblings, 1 reply; 11+ messages in thread
From: Bart Schaefer @ 1998-10-07 18:36 UTC (permalink / raw)
To: Greg Badros, zsh-users
On Oct 7, 10:50am, Greg Badros wrote:
} Subject: Re: Null tilde expansions?
}
} > Yes, you're right. Or just ${dirs##~*}, in which the ~ is not expanded
} > in the first place.
}
} Why does the ~ not get expanded? This doesn't work in 3.1.4 or 3.0.x
} for me. I need to escape the ~ with a backslash here, too.
I dunno, but:
aztec[26] gunk=(schaefer glorb bobg flarn fox)
aztec[27] dirs=(~$^gunk)
zsh: no such user or named directory: glorb
aztec[28] setopt nonomatch
aztec[29] dirs=(~$^gunk)
aztec[30] echo ${dirs##~*}
/home/schaefer /home/bobg /home/fox
aztec[31] echo $dirs
/home/schaefer ~glorb /home/bobg ~flarn /home/fox
aztec[32] echo $ZSH_VERSION
3.0.5-extended
(3.0.5-extended is 3.0.5 plus my patch collection, available on
ftp.brasslantern.com.)
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Null tilde expansions?
1998-10-07 18:36 ` Bart Schaefer
@ 1998-10-08 7:29 ` Peter Stephenson
0 siblings, 0 replies; 11+ messages in thread
From: Peter Stephenson @ 1998-10-08 7:29 UTC (permalink / raw)
To: Greg Badros, zsh-users
On Oct 7, 10:50am, Greg Badros wrote:
} Subject: Re: Null tilde expansions?
}
} > Yes, you're right. Or just ${dirs##~*}, in which the ~ is not expanded
} > in the first place.
}
} Why does the ~ not get expanded? This doesn't work in 3.1.4 or 3.0.x
} for me. I need to escape the ~ with a backslash here, too.
% echo $dirs
/home/user2/pws ~foobar
% unsetopt extendedglob
% echo ${dirs##~*}
/home/user2/pws
% setopt extendedglob
% echo ${dirs##~*}
/home/user2/pws ~foobar
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarotti 2, 56100 Pisa, Italy
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~1998-10-08 7:46 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-06 18:16 Null tilde expansions? Greg Badros
1998-10-07 1:13 ` Sweth Chandramouli
1998-10-07 3:54 ` Bart Schaefer
1998-10-07 15:00 ` Greg Badros
1998-10-07 15:11 ` Peter Stephenson
1998-10-07 15:26 ` Bart Schaefer
1998-10-07 15:41 ` Greg Badros
1998-10-07 16:47 ` Bart Schaefer
1998-10-07 17:50 ` Greg Badros
1998-10-07 18:36 ` Bart Schaefer
1998-10-08 7:29 ` Peter Stephenson
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).