From owner-freebsd-questions@FreeBSD.ORG Sat Mar 27 07:17:29 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 504E5106564A for ; Sat, 27 Mar 2010 07:17:29 +0000 (UTC) (envelope-from invalid.pointer@gmail.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 08A2A8FC12 for ; Sat, 27 Mar 2010 07:17:28 +0000 (UTC) Received: by gwj15 with SMTP id 15so5273348gwj.13 for ; Sat, 27 Mar 2010 00:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=hjATGsy9T3UjKf7MLtYQmdQh4uJfuGDyTlArQPu+bvI=; b=W5ZYf/b72KQYe8UtRXi/jrtBYMcCvpgcmxV0i2DbRzE7DlqR+Sw5YvatdqkJ1dchiG eXWnjceARHf4NPmpc7wHfXi1AoTUZqVfRyVWTKgrN6PH8xIHgzN2wqTaOtojzekq9ZW2 29emQtQxRmbLA3G/CYT/nNS/dqNvjgrF3EpVI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=WBCzf/CgpPQl/3hLy9qMSz/+dbeBuOiX5jkh9vuEBP8vffAtpUB0t/Uak9I9Kiz3Hk HQf3BhMDF+JDEIjKKf59MP+wzsAfFt8UKdJTSw9khS8SIvWgYkgtQGsXli0mVbkngMvF lX47veuLE+DdGdXGyue5BmVoRF4ZBZ274z2XY= Received: by 10.100.243.29 with SMTP id q29mr2983288anh.210.1269674248322; Sat, 27 Mar 2010 00:17:28 -0700 (PDT) Received: from [192.168.1.78] ([122.177.190.81]) by mx.google.com with ESMTPS id 22sm1548624iwn.8.2010.03.27.00.17.25 (version=SSLv3 cipher=RC4-MD5); Sat, 27 Mar 2010 00:17:27 -0700 (PDT) Message-ID: <4BAE60F6.1010003@gmail.com> Date: Sat, 27 Mar 2010 12:48:06 -0700 From: Manish Jain User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: Dan Nelson References: <4BAE5627.5010802@gmail.com> <20100327065100.GA4806@dan.emsphone.com> In-Reply-To: <20100327065100.GA4806@dan.emsphone.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: Question about expr X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Mar 2010 07:17:29 -0000 Dan Nelson wrote: > In the last episode (Mar 27), Manish Jain said: >> I am used to the normal GNU-version of expr (also available on Solaris) >> and much prefer it over the FreeBSD version. The GNU version allows >> internal commands like length, substring and others which make it much >> easier to work with. Is there any way I can replace FreeBSD's native expr >> with the GNU version ? Since I believe expr does not normally ship as a >> shell-builtin, I don't think the shell can of much help in the matter. >> >> Actually, I think it might not be a bad idea to place a port of GNU-expr >> in the ports directory. This would allow a lot a scripts to be readily >> portable to multiple environments. > > It's part of the coreutils package. If you install the sysutils/coreutils > port, you can symlink /bin/expr over to it (or make a copy). I don't know > if it's 100% compatible with BSD expr, though, so you may end up breaking > scripts in the base system. > Hello Dan, Thanks for the info. But I don't intend to symlink /bin/expr over to it. Instead I'll just create an alias in bash's profile and my scripts. That should let core scripts execute with /bin/expr and my scripts to use the GNU-version. Which actually leads me to second question : When you execute a script, it will automatically pick up the exports in .bash_profile. But even if you manually source bash's profile at the start of your script, only the exports get picked up and the aliases are ignored. Is there some way to fix this so that I don't have to set an alias for expr at the top each time I write a script ? Thanks & Regards Manish Jain invalid.pointer@gmail.com