Found some more matches in linuxquestions.org when searching for differences between ksh and bash
out of these the one by GazL is what caught my attention
bash isn't always the winner. ksh has some nice useful variable typing that bash doesn't.
It's much easier than
... and you don't have to keep reapplying the translation to ensure the value is lowercase should the value ever be changed. Very Useful for when dealing with user input.
I also prefer the ksh math syntax of
rather than bash's more unwieldy;
... but that's just a minor style thing.
The biggest difference that tends to catch people out though is this one...
ksh:
bash:
... Oi! bash!... where'd my variable go?
What makes this one particularly bad is that the bash code looks like it ought to work. It's only when you understand the underlying semantics of how bash deals with pipelines that you realise why it doesn't.
Because bash runs a pipeline in a sub-shell, you actually have to do it like this
mesiol also has a point
one reason for using ksh for scripting is, this shell is available on nearly all existing flavours of *nix. Bash is not installed by default on all *nix.
out of these the one by GazL is what caught my attention
Quote:
A script written to run in ksh would likely run in bash just fine. A lot of the differences deal with math, variables, arrays, functions etc... - bash just seems to have a hell of lot more of this than ksh
|
Code:
$ typeset -l lowercase_only $ lowercase_only="WiBbLe" $ echo $lowercase_only wibble
Code:
lowercase_only=$(echo "WiBbLe" | tr "[:upper:]" "[:lower:]")
I also prefer the ksh math syntax of
Code:
let a=b+c
Code:
a=$(( b+c ))
The biggest difference that tends to catch people out though is this one...
ksh:
Code:
$ echo wibble | read variable $ echo $variable wibble $
Code:
bash-3.1$ echo wibble | read variable bash-3.1$ echo $variable bash-3.1$
What makes this one particularly bad is that the bash code looks like it ought to work. It's only when you understand the underlying semantics of how bash deals with pipelines that you realise why it doesn't.
Because bash runs a pipeline in a sub-shell, you actually have to do it like this
Code:
read variable < <(echo wibble) echo $variable
mesiol also has a point
one reason for using ksh for scripting is, this shell is available on nearly all existing flavours of *nix. Bash is not installed by default on all *nix.
No comments:
Post a Comment