![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | 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 01:46 PM |
| korn syntax | sajjad02 | Shell Programming and Scripting | 1 | 09-27-2004 07:15 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 | ||
|
|
|
|||
|
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. |
|
||||
|
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 UNIX.COM |