From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: DervishD <raul@pleyades.net>
Cc: zsh-workers@sunsite.dk
Subject: Re: Recursion and shell functions
Date: Fri, 11 Oct 2002 10:02:37 +0100 [thread overview]
Message-ID: <E17zvgr-0003sa-00@bimbo.logica.co.uk> (raw)
In-Reply-To: <20021010194154.GA10963@DervishD>
On 10 Oct, you wrote:
> First of all, please excuse this a-bit-off-topic question, but I
> need to know if a feature available in zsh is portable.
>
> I need to do recursion in a directory tree and have two options;
> first one is doing a 'for' loop recursively calling the shell
> function which performs the actions:
> setting the permissions. This may seems unreasonable (two
> recursions...) but it's necessary since the recursive function call
> overwrites local variables, and I *cannot* set them as local, since
> 'local' is not a portable keyword :((( I need
If you know that you will at least have ksh88, you can get local
variables by using the function name { ... } syntax for functions and
using typeset to declare variables.
The bourne shell doesn't have local variables except for the
positional parameters and you can use them. I think this will be
portable:
func() {
set *
while [ "$1" ]; do
if [ -d "$1" ]; then
cd $1
func
cd ..
fi
shift
done
}
Something like find is going to be more reliable though.
Oliver
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
next prev parent reply other threads:[~2002-10-11 9:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-10 19:41 DervishD
2002-10-10 19:44 ` DervishD
2002-10-10 20:02 ` Jason Price
2002-10-10 21:15 ` DervishD
2002-10-11 9:02 ` Oliver Kiddle [this message]
2002-10-11 11:05 ` DervishD
[not found] ` <E1802KE-0001g0-00@bimbo.logica.co.uk>
2002-10-11 18:27 ` DervishD
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=E17zvgr-0003sa-00@bimbo.logica.co.uk \
--to=okiddle@yahoo.co.uk \
--cc=raul@pleyades.net \
--cc=zsh-workers@sunsite.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).