Re: Portability of $(expr) vs `expr` in bash



Hello Leonard,


On Sat, 30 Jul 2005 12:09:36 +0200 Leonard den Ottolander
<leonard den ottolander nl> wrote:

Hi wwp,

On Fri, 2005-07-29 at 08:53, wwp wrote:
If your concern is "bash" only:

Yes. Although I somewhat presumptuously assumed /bin/sh == bash. Not
sure if that is too presumptuous, or that this assumption is shared
throughout the code base.

Pavel is right. Some GNU/Linux distros make zsh or tcsh the default /bin/sh
(there are even some other shells, and I'm just dealing the most common on
GNU/Linux systems, not at all w/ Unices, BTW), and anyway even the user can
make its default sh to be another one (system-wide or not).

Question is now.. are the shell scripts in mc only bash-compliant? Is bash a
pre-requisite? If not, I suppose that a review of all shell scripts should
be done, for *sh portability purposes, if you care about this.


How old are the bash versions that don't support $(expr)?

Are there ways to use macros in .sh.in files to substitute with either
'`' & '`' or '$(' & ')'?

I can't state upon this, sorry. I would say that if your goal is to be
compliant to common bash-based systems (or to require it at least) which
means bash version >=2, using the most bash-like $() is good. If you want to
be *sh compliant or to suppose older bash versions, `` is more portable.
I'm not sure about what bash developers would recommend.. would using ``
(with bash in mind) be a lack of evolutivity? Do recent non-bash shell also
support $()? Why on Earth are there `` and $() in bash :-)..


Regards,

-- 
wwp



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]