开发者

KornShell (ksh) SegFault

开发者 https://www.devze.com 2022-12-19 01:33 出处:网络
I have found the following script causes a segmentation fault and core in KornShell (ksh) on AIX. Can anyone explain why I get the following results?

I have found the following script causes a segmentation fault and core in KornShell (ksh) on AIX. Can anyone explain why I get the following results?

  • Seg Fault

    doOutput(){
      Echo "Something"
    }
    
    doOutput() >&1
    

    OR

    doOutput(){
      Echo "Something"
    }
    
    echo `doOutput()`
    

  • No Output

    doOutput(){
      Echo "Something"
    }
    
    doOutput()
    

  • Correct

    doOutput(){
      Echo "Something"
    }
    
    doOutput 
    

    OR

    doOu开发者_如何转开发tput(){
      Echo "Something"
    }
    
    doOutput >&1
    


  • Calls to functions in shells such as ksh don't use parentheses. They are only used during function definition.

    Correct:

    doOutput(){
      Echo "Something"
    }
    
    doOutput
    

    If you call a function with parameters, you separate them using spaces (no parentheses):

    doOutput(){
      Echo "$1 and then $2"
    }
    
    doOutput go stop
    

    Incorrect:

    doOutput(){
      Echo "Something"
    }
    
    doOutput()
    

    Plus, why are you redirecting stdout to stdout (>&1)?


    You've found a bug in ksh, and only the authors thereof, or someone with access to the source, can explain it to you. Real ksh didn't used to be open source, but perhaps that's changed.

    0

    精彩评论

    暂无评论...
    验证码 换一张
    取 消