[CentOS] Real sh? Or other efficient shell for non-interactive scripts

Les Mikesell lesmikesell at gmail.com
Fri Apr 24 12:59:57 UTC 2015


On Fri, Apr 24, 2015 at 7:02 AM, mark <m.roth at 5-cent.us> wrote:
>
>>> I'm sure most people here know about Dash in Debian. Have there
>>> been discussions about providing a more efficient shell in Centos
>>> for use with heavily invoked non-interactive scripts?
>>>
>>> With sh being a link to bash in Centos I don't know if it would
>>> explode if the link was changed to something else, but at least
>>> the scripts we made on our own that run certain services could
>>> be changed and tested manually to another shell.
>>>
>>> Are there other people who have experience in this and can
>>> provide interesting guidance?
>>>
>> Why go to that extreme if you tell a script on line 1 which shell to run
>> it
>> will do so.
>> #!/bin/dash
>> or what ever shell you want it to run in.  I always do that to make sure
>> that
>> the script runs as expected, if you leave it out the script will run in
>> whatever environment it currently is in.
>>
>
> I'm confused here, too, and this has been bugging me for some time: why sh,
> when almost 20 years ago, at places I've worked, production shell scripts
> went from sh to ksh. It was only after I got into the CentOS world in '09
> that I saw all the sh scripts again.
>

The original ksh wasn't open source and might even have been an
extra-cost item in AT&T unix.   And the early emulations weren't
always complete so you couldn't count on script portability.  I
generally thought it was safer to use perl for anything that took more
than bourne shell syntax.

But as for efficiency, I'd think a script would have to do quite a lot
of work to offset the need to page in different code for the
interpreter.  Any unix-like system should almost always have some
instances of sh running and other instances of the same executable
should run shared-text, where invoking a shell that isn't already
loaded will have to load the code off the disk.

-- 
   Les Mikesell
     lesmikesell at gmail.com



More information about the CentOS mailing list