![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing variable from bash to perl from bash script | arsidh | Shell Programming and Scripting | 10 | 06-04-2008 09:25 AM |
| Why generate "ash and bash" different output for same bash script? | s. murat | Shell Programming and Scripting | 0 | 05-26-2008 04:19 AM |
| korn shell to bash - statement not working | brdholman | UNIX for Dummies Questions & Answers | 5 | 10-15-2007 06:49 AM |
| Korn Shell | gpanesar | Shell Programming and Scripting | 4 | 03-25-2005 02:46 PM |
| korn syntax | sajjad02 | Shell Programming and Scripting | 1 | 09-27-2004 07:15 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Korn vs Bash
Let's say I have
alias good_op=`[[ "$sign" = "+" || "$sign" = "-" ]]` in a Korn shell script. How can I write that in a non-interactive bash shell? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Have you tried that in bash? Bash implements some of the cool features of ksh, so that entire statement (possibly even most of your script) very well may work in bash.
|
|
#3
|
|||
|
|||
|
thanks, it didn't work in bash, but I found a way around:
using test, do, and done - test [ "$sign" = "+" -o "$sign" = "-" ]; do... not the most elegant, but it works. |
|
#4
|
||||
|
||||
|
I got your alias to work in bash. But when I do "bash --version", I get 2.03. I'm guessing that you are using an older version of bash.
The only feature that I miss in bash is the ksh co-process code. Once bash picks that up, I will probably switch to bash. |
|
#5
|
|||
|
|||
|
this is my version:
GNU bash, version 2.03.8(1)-release (i386-redhat-linux-gnu) Copyright 1998 Free Software Foundation, Inc. The alias will only work in an interactive shell. I get an interactive shell when I login, but any script that runs will start its own non-interactive shell. Oh, this is bash2. |
|
#6
|
||||
|
||||
|
You're right. I tested interactively and I can't get bash to use aliases at all in a script. A more elegant work-around is to switch to functions. I think the existence of functions is why both ksh and bash have weak alias commands. The function is:
good_op() { [[ $sign = + || $sign = - ]] ; } and yes, with the [[ command, you can drop all those double quotes you had. |
||||
| Google The UNIX and Linux Forums |