Question about expr

2010-03-27 Thread Manish Jain


Hello all,

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.


Thanks for any help.


Regards

Manish Jain
invalid.poin...@gmail.com

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Question about expr

2010-03-27 Thread Dan Nelson
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.

-- 
Dan Nelson
dnel...@allantgroup.com
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Question about expr

2010-03-27 Thread Manish Jain

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.poin...@gmail.com

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Question about expr

2010-03-27 Thread perryh
Manish Jain invalid.poin...@gmail.com wrote:
 When you execute a script ...  the aliases are 
 ignored. Is there some way to fix this ...

Search for expand_aliases in the bash manpage.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org