View Full Version : Is bash included in OpenBSD?
bsdnewbie999
06-16-2008, 02:35 AM
What terminals are available in OpenBSD for a newly installed system? Is there a port for bash and how do i change the default terminal to bash?
What terminals are available in OpenBSD for a newly installed system? Is there a port for bash and how do i change the default terminal to bash?
Default is Korn Shell. It is a OpenBSD "fork" of the public Korn Shell not to be mistaken with ATT Korn Shell and MidnightBSD Korn Shell .
Bash is available as a package. I do not think that Bash is very popular among BSD users and particularly not popular among OpenBSD users.
The part of the base system is Bourne shell of course because of Posix standard and I think C shell. I personally use Korn shell so I never bother to check.
ocicat
06-16-2008, 03:08 AM
What terminals are available in OpenBSD for a newly installed system?
the Korn shell (ksh).
the C shell (csh).
the restricted Korn shell (see the discussion for -r in ksh).
the Bourne shell (sh).
Note that with the last two, these are simply copies of /bin/ksh.
Is there a port for bash...
Yes, see the following list of shells found in packages/ports:
http://openports.se/shells
...and how do i change the default terminal to bash?
See the manpage for chsh.
This is also covered in Section 10.17 of the FAQ:
http://openbsd.org/faq/faq10.html#rootshell
Once you become comfortable with editing the password file, you can change the shell directly.
TerryP
06-16-2008, 05:31 AM
Just to chime in, bash is _n_o_t_ a terminal it is a shell.
Programs such as xterm are terminal emulators, the command line level interface through virtual teletypes when you first start the machine without X are 'virtual' consoles (not all that much different from a user point of view).
The shell runs in the console or terminal and should hopefully be fairly indifferent to which of them it runs in ;-)
PS
outside of bash specifics most things people expect of bash are doable in OpenBSDs pdksh implementation. A shell is mostly a shell for the most part unless you want to compare the other end of the pond.
marcolino
06-16-2008, 04:07 PM
Speaking as a long-time user of bash, who has only recently (since 4.2) switched to OpenBSD's ksh, there is nothing I could do in bash that I can't do in ksh.
That's one less port to have to install after a fresh system install.;)
lvlamb
06-16-2008, 04:16 PM
Install http://openports.se/sysutils/checkbashisms
and run your bash scripts through it.
If you want to be portable, you can run [pd]ksh with the POSIX options, much like the /bin/sh link in Linux does.
And, beeing OpenBSD stock, ksh code is audited!
ai-danno
06-16-2008, 06:26 PM
Speaking as a long-time user of bash, who has only recently (since 4.2) switched to OpenBSD's ksh, there is nothing I could do in bash that I can't do in ksh.
That's one less port to have to install after a fresh system install.;)
And that's nothing to scoff at- I believe you could call it a 'best practice' to keep your servers as lean as possible on the application installations. If you can accomplish what you need with what's already installed... then do so.
The other thing is that the rest of the OBSD community (as a whole, anyway) uses the default KSH... so you would be in better company using KSH instead.
marcolino
06-17-2008, 04:09 PM
And that's nothing to scoff at- I believe you could call it a 'best practice' to keep your servers as lean as possible on the application installations. If you can accomplish what you need with what's already installed... then do so.
The other thing is that the rest of the OBSD community (as a whole, anyway) uses the default KSH... so you would be in better company using KSH instead.Add to that the ease of upgrading from one release to the next. Ports can be deprecated and removed, causing all sorts of configuration problems. At least if you keep to using the base, when something changes, it will be well-documented, with any necessary changes plainly spelled out. Just take a look at any Upgrade Guide.
lvlamb
06-17-2008, 06:32 PM
OpenBSD as one of the best upgrading mechanism in the *nix world.
pkg_add -ui (man packages)
make update clean (man ports)
and
setting your FETCH_PACKAGES you would first grab the binary update if it exists instead of spending CPU time re-inventing warm water.
bsdnewbie999
06-18-2008, 01:30 AM
How do i enable this option ( [rooot @ user]$ ) to ksh like in linux does?
jggimi
06-18-2008, 01:58 AM
$ man ksh
/PS1
n
marcolino
06-19-2008, 08:26 PM
Just as an example, here is(are) the relevant line(s) from my .kshrcexport PS1='\[^[[1;36m\]\u\[^[[1;37m\]@\[^[[1;32m\]\h\[^[[0;34m\]\
(\l)\[^[[0m\]:\[^[[0;31m\]\w\[^[[0m\]\$ 'I highly suggest you do a Google search for color ksh prompts for more info.:)
ocicat
06-19-2008, 09:05 PM
Just as an example, here is(are) the relevant line(s) from my .kshrcexport PS1='\[^[[1;36m\]\u\[^[[1;37m\]@\[^[[1;32m\]\h\[^[[0;34m\]\
(\l)\[^[[0m\]:\[^[[0;31m\]\w\[^[[0m\]\$ '
As an addendum, I don't deal with ANSI colors on a frequent basis, so remembering all the appropriate sequences isn't something I attempt. Plus, changing or simply debugging the above string has its own set of problems -- especially months, if not years after I originally wrote the code.
My suggestion adding to marcolino's example is to break the string further down into more manageable chunks. What I do is the following:
green='^[[01;32m'
yellow='^[[01;33m'
blue='^[[01;34m'
no_color='^[[0m'
prefix="${green}\u${yellow}@${green}\h${yellow}:${blue}\w"
char="${yellow} $ ${no_color}"
export PS1="${prefix}${char}"
FWIW.
marcolino
06-20-2008, 08:20 PM
Let me say that ocicat is correct. Ideally, one should have a simple, easily-read and -maintained config file.
Having said that, I have had the same prompt for 10 years or so. The only time I had to delve back into the escape codes and ANSI colors was when I switched to ksh from bash. Once I figured out how to get the colors I wanted, I did not take the time to clean it up with variables. Shame on me and my laziness.:o
Once I get the time, I will probably do so. However, with the way my time has been lately, that probably won't be for a while.
But, yes, I advise to break the codes down into variables like ocicat said.
bsdnewbie999
07-30-2008, 01:33 PM
As an addendum, I don't deal with ANSI colors on a frequent basis, so remembering all the appropriate sequences isn't something I attempt. Plus, changing or simply debugging the above string has its own set of problems -- especially months, if not years after I originally wrote the code.
My suggestion adding to marcolino's example is to break the string further down into more manageable chunks. What I do is the following:
green='^[[01;32m'
yellow='^[[01;33m'
blue='^[[01;34m'
no_color='^[[0m'
prefix="${green}\u${yellow}@${green}\h${yellow}:${blue}\w"
char="${yellow} $ ${no_color}"
export PS1="${prefix}${char}"
FWIW.
I don't find my .kshrc file. Can you paste your .kshrc file here? Last thing, where should i put it ?
scottro
07-30-2008, 06:41 PM
I have a VERY dated Stupid Korn Shell tricks which goes through some colorizing.
http://home.nyc.rr.com/computertaijutsu/ksh.html
These days, with work being mostly in Linux, I'm used to bash again. On FreeBSD, I still tend to use zsh. Unfortunately, in Fedora at least (my main workstation) sh doesn't seem to be completely POSIX compliant, and I try to make my scripts usable on AIX as well. However, there's another shell, dash, which is supposedly completely POSIX compliant, pretty much like the FreeBSD sh.
Carpetsmoker
07-30-2008, 10:45 PM
I don't find my .kshrc file. Can you paste your .kshrc file here? Last thing, where should i put it ?
If the file doesn't exist, the create it.
.kshrc should be in your home folder.
ocicat
07-30-2008, 11:12 PM
I don't find my .kshrc file.
Studying the ksh manpage would be a wise use of time.
bsdnewbie999
07-31-2008, 03:00 AM
i added .kshrc file but it doesn't run at startup. I need to run . .kshrc everytime when i start gnome-terminal.
I add the line PS1 to both .profile and .kshrc and it is still the same.
BSDfan666
07-31-2008, 03:19 AM
You don't need it in both .profile and .kshrc, the former is used by login shells.. the latter for interactive. (For the most part, a .profile is all you'll normally need..)
When you define something in your profile, you need to 'export' it.
PS1="..."
export PS1
or:
export PS1="..."
After changes, you need to login again... if this doesn't work, please post the relevant section of the files here in tags.
J65nko
07-31-2008, 03:23 AM
I don't use gnome, but with the normal X xterm you need the -ls parameter. From xterm(1): -ls This option indicates that the shell that is
started in the xterm window will be a login shell
(i.e., the first character of argv[0] will be a
dash, indicating to the shell that it should read
the user's .login or .profile).Only then xterm will read the shell initialization files like .profile and .kshrc.
bsdnewbie999
08-02-2008, 03:57 AM
i see. :)
vBulletin® v3.7.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.