DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 13th March 2014
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default which shell is better?

Since it has not been mentioned yet:
The default shell in OpenBSD is ksh, which is pdksh with many decades of OpenBSD work on top of it.

Since you mention you know some bash programming, be aware that some bits of shell programming that you know may not work on ksh.
Reply With Quote
  #2   (View Single Post)  
Old 14th March 2014
Roydd85 Roydd85 is offline
Real Name: Roy
Port Guard
 
Join Date: Mar 2014
Location: Dallas, TX
Posts: 26
Default

I discovered that early this morning while messing around with commands. In all of your opinions, is the Korn shell better than the Bourne again shell? I only ask because I have heard nothing but good things about Ksh while I know a guy who uses Ksh on his Mint Linux and hates BASH and I never actually thought to ask him why.

Edit: I just found a 56 part lesson on Ksh on youtube. The guy seems to know his stuff. I think I will be spending the next 6 hours finding out the answer to my own question.

Last edited by Roydd85; 14th March 2014 at 12:13 AM.
Reply With Quote
  #3   (View Single Post)  
Old 14th March 2014
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by Roydd85 View Post
...is the Korn shell better than the Bourne again shell?
Context may help you arrive at the best answer for you, yourself. Any shell scripts provided in a base installation are written to OpenBSD's ksh(1) shell. It is not advisable for users to switch what shell root uses without extensive knowledge of what these scripts do.

However, what shell is used in a user account is a matter of personal opinion & taste.

Personally, I would advocate writing any & all personal shell scripts to be sh(1) compatible as all other shells (should) treat the Bourne shell (not BASH...) as the lowest common denominator when it comes to compatibility. This will help keep your work shell agnostic as most shells should be able to interpret Bourne shell scripts. Having said that, all shells do not interpret every script targeting the Bourne shell in the same manner, so your mileage may vary (YMMV).

Likewise, if you have specific reasons for targeting your work to using BASH specific features, go for it. You are free to write scripts any way you want.

Reply With Quote
  #4   (View Single Post)  
Old 14th March 2014
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

I'm separating this side discussion on shells from its parent thread:

http://daemonforums.org/showthread.php?t=8414

Most members of this site regularly mine the archives for past discussions on specific topics. To help aid those who may be reading old threads far into the future, we ask members to limit discussion to a single topic as set forth by the initial message in the thread. This helps keep discussion clear given the complexity of some subjects, & this also aids those whose primary language is not English.
Reply With Quote
  #5   (View Single Post)  
Old 14th March 2014
Roydd85 Roydd85 is offline
Real Name: Roy
Port Guard
 
Join Date: Mar 2014
Location: Dallas, TX
Posts: 26
Default

I have Linux on my desktop and I just put OpenBSD on my laptop. I was curious mostly because of any possible portability problems with scripts that I may write on one or the other. I suspect that for the stuff that I will be doing they will be mostly interchangeable since I don't see too many major differences, although BASH does seem to have more features like the history and process subbing. If it is a best practice to write in regular Bourne shell then I guess the question is largely irrelevant.

On a side note, I felt awfully stupid after refreshing the board and saw this topic. I thought " Damn, someone asked the same question before I did!"
Reply With Quote
  #6   (View Single Post)  
Old 14th March 2014
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default

I think if you're really new to the Unix world, it makes sense to stick with the default shell unless you have a pressing need for something that bash or some other shell provides and the shell you are using now does not. Learn Bourne (and/or POSIX) shell scripting. Once you get to the point where the differences in shells is meaningful to you, you'll already be armed with enough shell (and Unix) knowledge to make the best choice for you.

For what it's worth, I've never had a reason to use anything other than OpenBSD's ksh.

EDIT: Would you mind sharing the link to the ksh videos? I'm sure others would find that useful.

Last edited by ibara; 14th March 2014 at 01:51 AM.
Reply With Quote
  #7   (View Single Post)  
Old 14th March 2014
Roydd85 Roydd85 is offline
Real Name: Roy
Port Guard
 
Join Date: Mar 2014
Location: Dallas, TX
Posts: 26
Default

Here is the youtube link. I am about 5 videos in and I notice this is really targeting beginners, so this is good for me and others im sure. Maybe even some experienced folks can get a refresher?
http://www.youtube.com/user/bjamesm70/videos
Reply With Quote
  #8   (View Single Post)  
Old 14th March 2014
thirdm thirdm is offline
Spam Deminer
 
Join Date: May 2009
Posts: 248
Default

Quote:
Originally Posted by Roydd85 View Post
In all of your opinions, is the Korn shell better than the Bourne again shell?
For what I do with shell I find them nearly indistinguishable. The most noticable difference seems the documentation. Looking up things in ksh means reading a man page. Bash seems to have a man page (at least on NetBSD) but also has info pages. But since I don't even know and am not that interested right now in what extra useful features bash has I prefer ksh for being smaller and being in base and heavily used in OpenBSD.

I have heard of someone (Bradley Kuhn of Software Conservancy and FSF, IIRC) who had his whole command line history for all time (like over a decade or something) available in his bash command history. I don't know if that's possible or not in OpenBSD's pdksh. Seems to me Bradley contributed something to bash to make it possible, so maybe not.

If the idea of less is more comes to appeal extra strongly to you, perhaps it's worth looking (someday?) at what plan 9 chose for their default shell: rc. I've been playing with it a little along with acme using plan9port, but it's bin a bit rough because my system now has two personalities: regular Unix and plan 9 wannabe (actually, three counting emacs).

Another interesting obscure shell out there is inferno's. Particularly intriguing there is that it has some kind of extensibility support via a module interface.

Finally, as a counterpoint to Unix admiration it might someday be worth reading Olin Shivers's paper criticizing Unix shell scripting and describing his scsh shell (but only if you first start learning lisp some?).

But getting back to reality, I agree it's probably best that you should start with ksh. When scripting be sure to use pdksh in "sh mode", i.e. /bin/sh not /bin/ksh, so you're only using standard bourne shell features, not the ksh extensions. It might be a useful exercise to diff the manual pages sh(1) and ksh(2).
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I run a shell command in a while loop? steamrent OpenBSD General 4 6th December 2011 08:42 AM
ask for a shell script Simon Programming 5 27th April 2010 01:07 AM
Shell Scripting with BSD chavez243 Programming 9 3rd December 2008 03:03 AM
Color shell? giga FreeBSD General 3 14th August 2008 12:07 AM
Shell Script. bsdnewbie999 Programming 21 15th July 2008 07:54 AM


All times are GMT. The time now is 06:17 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick