# Choosing a shell for scripts and interactive use



## nickednamed (Sep 1, 2013)

I'm trying to teach myself shell scripting and I've been wondering what more experienced shell programmers have to say regarding using the same shell for both interactive use and scripts versus using different shells for each. So according to personal experience:


Does using the same shell for both reduce the learning curve and/or speed up learning time?


Does using two different shells have any benefits (other than the interactive features you may get from a particular shell such as zsh), or will it just confuse a "noob"?


----------



## ShelLuser (Sep 1, 2013)

nickednamed said:
			
		

> Does using the same shell for both reduce the learning curve and/or speed up learning time?
> Does using two different shells have any benefits (other than the interactive features you may get from a particular shell such as zsh), or will it just confuse a "noob"?


In my opinion it's impossible to answer since it all depends on the person who's using all this. But I realize that this obviously doesn't really help you at all, so let's try anyway 

I do indeed think that there are some benefits in using the same shell on the console as the one you're going to use in your scripts. Don't forget that in the end a shell script is basically nothing more than a bunch of instructions which are fed to, well, a shell. But generally there isn't much difference between stacking all the commands up in a file, or executing them on the console one by one.

The main benefit should be obvious: it's easier to try a command on the console than having to edit a file, change the things you're experimenting on, saving and then finally executing it.

Do keep in mind that I'm talking about using a shell, not so much about which shell should be assigned to a user account. Simply because it's quite easy to start using a different shell:


```
smtp2:/home/peter $ echo $0
-ksh
smtp2:/home/peter $ sh
set: Illegal option -o posix
$ echo $0
sh
$
```
Don't mind the error message up there, that's because I'm lazy and edited .profile in my home directory to include some specific settings for ksh.

But what I'm getting at; as soon as I started sh I now have the same interactive shell as the one I'm always using in my shell scripts. While I'm normally always using ksh.

Which brings me to your second question. I do indeed think that there are benefits in using different shells. In fact, I'm actually using 3 on my system: sh which is used in all my shell scripts, ksh which I'm using on my personal account and csh which is used for the root account.

The benefit here is the feature set combined with personal preference. I prefer ksh over bash for example because of some specific features and because I consider bash to be a bit "bloated" (which isn't true perse mind you).

As to confusing a newbie..  I don't think so. In fact; I only see a benefit here. In my opinion the first step in building shell scripts is to realize that there actually are different shells out there. Normally a shell script begins with the 'she bang' after all:


```
#!/bin/sh
echo Hello sh world!
```

Hope this can help.


----------



## wblock@ (Sep 1, 2013)

For me, it is not confusing to use different shells for programming (sh) and interactive use (csh) because the two uses hardly overlap at all.


----------



## nickednamed (Sep 4, 2013)

I guess I'll keep doing what I'm doing then! That is bin/sh for scripts and shells/zsh for interactive use.


----------

