From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10552 invoked from network); 10 Oct 2002 19:43:24 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 10 Oct 2002 19:43:24 -0000 Received: (qmail 7907 invoked by alias); 10 Oct 2002 19:43:06 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17801 Received: (qmail 7885 invoked from network); 10 Oct 2002 19:43:04 -0000 Date: Thu, 10 Oct 2002 21:41:54 +0200 From: DervishD To: Zsh Subject: Recursion and shell functions Message-ID: <20021010194154.GA10963@DervishD> Mail-Followup-To: Zsh Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4i Organization: Pleyades Net Hi all :)) 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: function () { for item do if [ -d $item ] then do_some_action chmod u+w $item cd $item function <-- Overwrites 'item', of course chmod u-w $item <-- Oh-oh... $item is not as before... ... fi fi ... } Second is using 'find' to do the proper operations, although I don't want the piece of software dependent on 'find'. The problem is if I can do recursion safely (well, portably), if it is supported by POSIX (I can't find a word about it in SuSv3) or at least if it is common practice: don't want to find a tiny non-interactive shell failing because of this... Just in case you can help me, I need to copy a hierarchy from one place to another (where some files can be already present) setting permissions in the process. Other solution I'm considering is doing a 'cp -fpR' over the tree and after that the recursion above for 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 Suggestions welcome and thanks in advance :)) Raśl