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

Re: Help on filename generation

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

> 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