What shell does the *operating system itself* use?

I know tcsh & sh are defaults for root & users, but what does freeBSD use for it's own tasks?
Such as system start-up and package management...
I'd like to use the same shell so that there would be just one shell on my system.
I.e. what is the one shell that musnt be removed because the OS uses it?

I hope this makes sense; I searched alot, but could only verify that some rc scripts use sh.
thanks
 
Code:
# grep -r ^"\#\!" /etc /usr/bin /bin /sbin /usr/sbin | grep -c /bin/sh
268
# grep -r ^"\#\!" /etc /usr/bin /bin /sbin /usr/sbin | grep -vc /bin/sh
3

Those 3 are perl.
 
+ system start-up done via /bin/sh
+ */rc.d/* done via /bin/sh
+ most package management tools are written in C or perl or other shell scripting.
 
rivercat said:
I'd like to use the same shell so that there would be just one shell on my system.
I.e. what is the one shell that musnt be removed because the OS uses it?
That would be /bin/sh but unless you enjoy a rather spartan shell I suggest setting your shell to /bin/tcsh.
 
SirDice said:
That would be /bin/sh but unless you enjoy a rather spartan shell I suggest setting your shell to /bin/tcsh.
Are you trying to start a flame war;) I like better Korn (OpenBSD) or Mir Korn shell (mksh) on FreeBSD. Actually to go back to original question /bin/sh is a Posix shell. He needs to have sh to be able to execute scripts.
 
Oko said:
Are you trying to start a flame war;)
Not really :e but (t)csh has been the 'standard' shell on freebsd for users since I can remember.

I like better Korn (OpenBSD) or Mir Korn shell (mksh) on FreeBSD.
Never could get the hang of Korn but then again I never have put much effort into it :r
 
Dammit.
It was because of (ba)sh that was considering leaving Slackware linux. sh seemed bloated and inconsistent.
Then I find out "freeBSD's default for root is tcsh", and think I've found my solution.

Can anyone name a distro that uses the smallest/lightest shell? zsh? ash?
 
DutchDaemon said:
Code:
# grep -r ^"\#\!" /etc /usr/bin /bin /sbin /usr/sbin | grep -vc /bin/sh
3
Those 3 are perl.

You mean even perl is a nescessity for freeBSD to run?
 
Oko said:
I like better Korn (OpenBSD) or Mir Korn shell (mksh) on FreeBSD.

Is Korn the only shell required for OpenBSD?

For FreeBSD, would Mir Korn (mksh) suffice as the only shell?
 
rivercat said:
You mean even perl is a nescessity for freeBSD to run?
Run it without the -c flag:
Code:
# grep -r ^"\#\!" /etc /usr/bin /bin /sbin /usr/sbin | grep -v /bin/sh
/usr/bin/mmroff:#! /usr/bin/perl
/usr/bin/afmtodit:#! /usr/bin/perl -w
/usr/sbin/ntptrace:#! /usr/local/bin/perl -w
#
So, no. But to use those three tools, yes.
 
rivercat said:
It was because of (ba)sh that was considering leaving Slackware linux. sh seemed bloated and inconsistent.
Do realize that every unix and unix-like system supports (and uses!) the Bourne shell (that's /bin/sh). So if you want portability the Bourne shell is the rule (OpenBSD also relies on the Bourne shell; /bin/sh for it's startup scripts). Also realize that the /bin/sh on most linux systems is actually the Bourne Again shell (that's /bin/bash) with the 'extra' features turned off, hence the 'bloated' /bin/sh.

Then I find out "freeBSD's default for root is tcsh", and think I've found my solution.
Yes, but don't even think about removing /bin/sh!

Can anyone name a distro that uses the smallest/lightest shell? zsh? ash?
Zsh certainly isn't small by any standards. It's also not part of the base system, neither are ash, mksh and bash. This means you will have to install additional ports if you want them. So I'd say stick to FreeBSD :e

Why are you so concerned about a few KB when the whole system takes up much more than that?


As a side note, perl isn't part of the base system anymore so any pkgtool that's part of the base OS cannot use perl.
 
Just a note: the /bin/sh present in FreeBSD is NOT actually the Bourne Shell, it's the POSIX shell. The Bourne Shell came from AT&T and thus had to be replaced when in order for BSD to be releasable to people who didn't have a source license from Bell Labs. While the Bourne Shell was eventually open sourced along with the rest of 7th Edition Unix, that was over a decade after it had been replaced in the various BSDs...
 
SirDice said:
Why are you so concerned about a few KB when the whole system takes up much more than that?
I was hoping tcsh would be easier to learn than sh, since I had some C exposure. I hate it when languages use different syntax for the same constructs.

fi?
esac?
God what was wrong with ) or }x:)(
Bash doesnt seem to 'Keep it simple stupid'.

Thanks for helping a newb though...
 
rivercat said:
I was hoping tcsh would be easier to learn than sh, since I had some C exposure. I hate it when languages use different syntax for the same constructs.

fi?
esac?
God what was wrong with ) or }x:)(
Bash doesnt seem to 'Keep it simple stupid'.
Steve Bourne was an Algol 68 fanatic...

But he also (rightly I think) didn't want to make his shell too foreign for the simple routine stuff.

Can you imagine having to type
$ ls();

instead of
$ ls

or
$ cat(a, b, c) | tr();

instead of
$ cat a b c | tr

He obviously decided not to tackle expressions either.

And I think it was right not to use {} for blocks...

The shell does a lot of string processing, and C is a pretty terrible language for that...

Basically Bourne keep nearly all of the V6 shell syntax for command line processing (pipelines, metacharacters, string substitution, etc), but completely overhauled the flow control aspects of the V6 shell, which were practically non-existent anyways (remember goto(1), which does a seek() followed by a search for a : label)?
 
rivercat said:
Is Korn the only shell required for OpenBSD?

For FreeBSD, would Mir Korn (mksh) suffice as the only shell?
No of course not. How are you going to run scripts? We went over that. Every POSIX complaint system must have POSIX version of sh. All scripts should be written in sh. On the top of that system usually have one maybe two other shells. In OpenBSD that other shell happens to be Public Korn Shell (pksh) which is heavily patched for security reasons. It is de-facto OpenBSD version of public korn shell. Mir Korn is another free implementation of Korn Shell. Default OpenBSD installation contains third shell (csh). It is original Berkeley implementation
of C shell.

If you are on proprietary Unix you can use Korn93 shell which is very, very good.

NetBSD default shell is just sh.

As you heard before FreeBSD default shell is tcsh.It is not good idea to replace default shell for root account! There are lots of threads about that on this forum.
 
Oko said:
If you are on proprietary Unix you can use Korn93 shell which is very, very good.
Ksh93 has been FOSS for a number of years. There's no need to be on a proprietary system to use it. It's in the ports tree even. It didn't build correctly for me :(
 
Try it with -DNO_PROPRIETARY_UNIX.

(seriously, don't bother..)
 
mjkerpan said:
Ksh93 has been FOSS for a number of years. There's no need to be on a proprietary system to use it. It's in the ports tree even. It didn't build correctly for me :(

Q8. Is KornShell public domain?
A8. Yes, the language description is public domain and
can be reimplemented. Some of the KornShell language
features have been reimplemented in the GNU shell, bash
and in pdksh, a public domain implementation.

Q9. Is ksh public domain?
A9. No, earlier versions were owned by both AT&T and Novell.
The 1993 version is owned by both Lucent and AT&T.

I guess that probably explains why it failed to build for you ;)
 
SirDice said:
Not really :e but (t)csh has been the 'standard' shell on freebsd for users since I can remember.

The default shell for non-root users has been /bin/sh since pretty much the dawn of time. The default shell for root user(s) is /bin/tcsh. At least, that's the defaults for sysinstall and adduser. :)
 
rivercat said:
It was because of (ba)sh that was considering leaving Slackware linux.

Mhm - that is one weird reason why to leave Slackware.

Write scripts in posix shell (/bin/sh), you should have no problems porting them anywhere. It should resist even evil /bin/sh being a symlink to something else on Linux.

Personally I write scripts in posix shell, but I do use either bash or korn shell (shells/ksh93) with vi mode set on as a user shell.
 
I'm sure the OP figured it out after almost 2 years. Please look at the date before replying.
 
Oko said:
No of course not. How are you going to run scripts? We went over that. Every POSIX complaint system must have POSIX version of sh.

Actually, FreeBSD’s /bin/sh is not a POSIX sh. In some points, it even goes against what POSIX requires.

If you compile mksh with the following options:
  • -DMKSH_MIDNIGHTBSD01ASH_COMPAT (enable compatibility to MidnightBSD 0.1 ash (/bin/sh) when set -o sh is run)
  • -DMKSH_BINSHREDUCED (imply set -o sh when the shell is called as sh or -sh as its last path component)
Then I believe it’s possible to run a FreeBSD® system with only the resulting mksh binary, installed in /bin/mksh and hardlinked in /bin/sh (or just installed as /bin/sh but who’d want that? ☺).
 
Back
Top