1821245 Members
2710 Online
109632 Solutions
New Discussion юеВ

korn and borne shell

 
SOLVED
Go to solution
Shivkumar
Super Advisor

korn and borne shell

Dear Sirs;

If a process needs to be started as korn shell and someone by mistake starts in bourne shell then what would be the repercussion of this ?

Thanks,
Shiv
8 REPLIES 8
morganelan
Trusted Contributor

Re: korn and borne shell

The Korn shell is almost completely backward-compatible with the Bourne shell. The only significant feature of the latter that the Korn shell doesn't support is ^ (caret) as a synonym for the pipe (|) character. [1] This is an archaic feature that the Bourne shell includes for its own backward compatibility with earlier shells. No modern UNIX version has any shell code that uses ^ as a pipe.

There are also a few differences in how the two shells react to certain extremely pathological input. Usually, the Korn shell processes correctly what causes the Bourne shell to "choke."

The Bourne shell is the standard shell and provides the following features:

*Input/output redirection.
*Wildcard characters (metacharacters) for filename abbreviation.
*Shell variables for customizing your environment.
*A built-in command set for writing shell programs.
*Job control (beginning in SVR4).

The Korn shell is a backward-compatible extension of the Bourne shell. Features that are valid only in the Korn shell are so indicated.

*Command-line editing (using vi or emacs).
*Access to previous commands (command history).
*Integer arithmetic.
*More ways to match patterns and substitute variables.
*Arrays and arithmetic expressions.
*Command name abbreviation (aliasing).
Kamal Mirdad
Yogeeraj_1
Honored Contributor

Re: korn and borne shell

hi,

the Korn shell is more complex than the bourne shell such that it has a wider set of commands!

the risk is that some commands may not execute properly but this is much unlikely...

Normally, you can force a script to use a particular shell by specifying the shell to use:

e.g. the first line would be:
#!/bin/sh

or
#!/bin/ksh

again read page 468 of marty's book!

regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Indira Aramandla
Honored Contributor

Re: korn and borne shell

Hi Shiv,

The Bourne shell is the standard shell and provides the following features:
Input/output redirection.
Wildcard characters (metacharacters) for filename abbreviation.
Shell variables for customizing your environment.
A built-in command set for writing shell programs.
Job control (beginning in SVR4).


The Korn shell is a backward-compatible extension of the Bourne shell. Features that are valid only in the Korn shell are so indicated.
Command-line editing (using vi or emacs).
Access to previous commands (command history).
Integer arithmetic.
More ways to match patterns and substitute variables.
Arrays and arithmetic expressions.
Command name abbreviation (aliasing).

Never give up, Keep Trying
Joseph Loo
Honored Contributor

Re: korn and borne shell

hi shiv,

refer to these docs:

http://docs.hp.com/en/B2355-90046/ch15s03.html

http://docs.hp.com/en/B2355-90164/ch03s04.html

regards.
what you do not see does not mean you should not believe
Mahesh Kumar Malik
Honored Contributor

Re: korn and borne shell

Hi Shiv

Following links may be of help for the subject

http://docs.hp.com/en/B2355-90046/ch01s01.html

http://docs.hp.com/en/B2355-90046/ch15s03.html

Regards
Mahesh
Bill Hassell
Honored Contributor
Solution

Re: korn and borne shell

It is VERY important to write all scripts with the required interpreter line as the very first line. This is not just as Bourne vs. Korn vs. POSIX shell problem, it affects scripts written in Perl and other interpretive languages. The first line should be:

#!/usr/bin/ksh
...rest of script...

NOTE: /bin is not a directory anymore, and it exists (just like in Solaris and other modern Unix systems) as symbolic link to /usr/bin. Also note that unless the user logged in and typed the command: /us/old/bin/sh, yiou are not running the Bourne shell. The default shell for HP-UX (unlike other Unix flavors) is /usr/bin/sh (/sbin/sh for root) and is a POSIX shell, virtually identical to Korn shell and other POSIX-compliant shells like bash.

If you run a script without the interpreter line, then the current shell will be invoked to run the script. If your Korn shell script has a statement like:

export x=1

then you'll get an error message:

x=1: is not an identifier

if you are running the Bourne shell but it is perfectly valid in a POSIX shell.


Bill Hassell, sysadmin
Sandman!
Honored Contributor

Re: korn and borne shell

I totally agree with Bill...Korn shell is similar to POSIX which in turn is a superset of Bourne. However to ensure that scripts written in a particular shell always start in the same it is imperative to make the first line of your script as follows...hash bang and the whole shebang:

#!/usr/bin/ # Bourne or Korn or POSIX.

This way nobody can accidentally launch scripts in a shell meant for another shell.

cheers!
rmueller58
Valued Contributor

Re: korn and borne shell

Shiv,

Is your bourne shell program a subshell? If so at the outside it may require a minor environment tweak at the top of your shell script.

What is does the script do, how does it work may provide others here with insight as to whether it will complete successfully or fail.

I generally write my scripts for bourne, as this is the most backward compatible. However, I have many scripts written for korn specifically and must be initiated in a korn. No way around it. They crash if ran in anything other then korn or bash. bash will run korn shells, (bourne again shell) is generally incorporated on Linux, and is not native to HP/UX, there is a port for it.