From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116 invoked from network); 6 Aug 2004 10:59:13 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 Aug 2004 10:59:13 -0000 Received: (qmail 53676 invoked from network); 6 Aug 2004 10:59:07 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Aug 2004 10:59:07 -0000 Received: (qmail 842 invoked by alias); 6 Aug 2004 10:58:24 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7804 Received: (qmail 831 invoked from network); 6 Aug 2004 10:58:24 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 6 Aug 2004 10:58:24 -0000 Received: (qmail 51812 invoked from network); 6 Aug 2004 10:56:53 -0000 Received: from madrid10.amenworld.com (62.193.203.32) by a.mx.sunsite.dk with SMTP; 6 Aug 2004 10:56:50 -0000 Received: from DervishD.pleyades.net (212.Red-80-35-44.pooles.rima-tde.net [80.35.44.212]) by madrid10.amenworld.com (8.10.2/8.10.2) with ESMTP id i76Aumw11634 for ; Fri, 6 Aug 2004 12:56:49 +0200 Received: from raul@pleyades.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1Bt2Nx-0006II-00>; Fri, 6 Aug 2004 12:55:41 +0200 Date: Fri, 6 Aug 2004 12:55:41 +0200 From: DervishD To: Zsh Users Subject: Getting a particular char Message-ID: <20040806105541.GE24158@DervishD> Mail-Followup-To: Zsh Users Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4.2.1i Organization: Pleyades X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-1.5 required=6.0 tests=BAYES_01 autolearn=no version=2.63 X-Spam-Hits: -1.5 Hi all :) First of all, my excuses because although this is a shell related question, is not exactly a zsh related question. Is more about portability, about how to implement a zsh facility in portable shell. If I want to get the character number 'n' from a parameter, in zsh I do something like: $parameter[n]. Easy, short... and non portable. So I change it to something like 'expr substr $parameter n 1'. This has some problems, like '$parameter' needing some tweaking so 'expr' doesn't whine because it starts with '(', '+', etc. or it is something like the word 'match'. But all that is not important, because the 'substr' expression is not SUSv3 compliant, so I cannot do that neither. So I'm implementing it like that: # Dirty and ugly hack, needs some polishing... # First we get rid of all characters at the beginning while [ ${#parameter} -gt n ] do parameter=${parameter#?} done # Now, get rid of the characters after # the one we are interested in while [ ${#parameter} -gt 1 ] do parameter=${parameter%?} done I would like another ideas, shorter, faster, or simply less ugly, and it must be portable, so no zsh tricks :(( If you could please help me... Thanks a lot in advance. Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.pleyades.net & http://raul.pleyades.net/