Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Help on filename generation
- X-seq: zsh-users 11606
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Help on filename generation
- Date: Tue, 10 Jul 2007 22:14:44 +0100
- In-reply-to: Message from jadamson@xxxxxxxxxxxx (Joel J. Adamson) of "Tue, 10 Jul 2007 15:13:22 EDT." <87bqekgjhp.fsf@xxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
Joel J. Adamson wrote:
> Oh, since you seem eager to help, that's not the function -- this is
> the function:
> ----------------------------------------
> function doit() {
Remove the "function".
> for file in $1/*(generic)*
As discussed previously.
> # no backup files $1/data/*(generic)*~*(~)
> do
> filename=${file##$1}
> newfilename=${filename/\/generic/$title}
> cp $file ./$newfilename
> ci -u -zLT $newfilename
You need
ci -m'updated' -u -zLT $newfilename
(or some more informative message) to stop being prompted
for a message. "man ci" should explain it (though it certainly
helps to know what you're looking for first).
> chgrp biostat ./$newfilename # how do I make this the default behavi
> or?
The command "newgrp <group>" starts up a shell with a different default
group, so that becomes the default for files you create; that's
interactive, I don't know of any easy way non-interactively.
(I've noticed that to be able to use newgrp on recent Linux systems
you need to be a member of the group in /etc/gshadow, not just
/etc/group).
> In general, how do I
> answer an interactive prompt within a shell function (i.e.,
> non-interactively)?
The general answer's fairly tricky. It depends a great deal on how the
programme is written. If it's simple, it's just a question of
redirecting input into it with "<". If it's not, however---if it's
something like "telnet" that really expects interactive input---and you
can't avoid using that programme, then you're stuck with nasty tricks
with pseudoterminals. Zsh provides a module zsh/zpty, documented in
zshmodules, that helps with this, but it tends to take some playing
around to get a programme to respond helpfully.
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author