[20231123]函式與bash shell呼叫.txt

lfree發表於2023-11-29

[20231123]函式與bash shell呼叫.txt

--//前一陣子調式bash shell時遇到的問題:

$ ./kd_off.sh 4,155 n
./kd_off.sh: line 9: rlbbed: command not found
./kd_off.sh: line 10: rlbbed: command not found
./kd_off.sh: line 11: rlbbed: command not found
./kd_off.sh: line 15: rlbbed: command not found
x /rn dba 4,155 offset 0
x /rn dba 4,155 offset 0

./kd_off.sh: line 30: rlbbed: command not found
sb2 kd_off[-2]                                 @2         0
sb2 kd_off[-1]                                 @4         0


--//原來我機器上的rlbbed是定義為函式,這樣呼叫無法訪問,如果使用alias就沒有問題。
$ export RLWRAP=$(which rlwrap)
$ type rlbbed
rlbbed is a function
rlbbed ()
{
    cd /home/oracle/bbed;
    $RLWRAP -s 9999 -c -r -i -f /usr/local/share/rlwrap/bbed $ORACLE_HOME/bin/bbed parfile=bbed.par cmdfile=cmd.par
}

--//得到別人的提醒,可以使用export -f rlbbed.測試看看.
--//執行如下類似
--// declare -x -f NAME

$ export -f rlbbed

$  ./kd_off.sh 4,155 n
x /rn dba 4,155 *kd_off[2]
x /rn dba 4,155 *kd_off[3]
x /rn dba 4,155 *kd_off[4]
x /rn dba 4,155 *kd_off[5]
x /rn dba 4,155 *kd_off[6]
x /rn dba 4,155 *kd_off[7]
x /rn dba 4,155 *kd_off[8]
x /rn dba 4,155 *kd_off[9]
x /rn dba 4,155 *kd_off[10]
x /rn dba 4,155 *kd_off[11]
x /rn dba 4,155 *kd_off[12]
x /rn dba 4,155 *kd_off[13]
x /rn dba 4,155 offset 7977
x /rn dba 4,155 offset 7965

sb2 kd_off[0]                               @136      8020
sb2 kd_off[1]                               @138      8008
sb2 kd_off[2]                               @140      7996
sb2 kd_off[3]                               @142      7984
sb2 kd_off[4]                               @144      7972
sb2 kd_off[5]                               @146      7960
sb2 kd_off[6]                               @148      7948
sb2 kd_off[7]                               @150      7936
sb2 kd_off[8]                              @152      7924
sb2 kd_off[9]                              @154      7912
sb2 kd_off[10]                              @156      7900
sb2 kd_off[11]                              @158      7889
sb2 kd_off[12]                               @160      7877
sb2 kd_off[13]                               @162      7865

--//如何取消呢?我不知道.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2997853/,如需轉載,請註明出處,否則將追究法律責任。

相關文章