Unable to unbind a shell function

无人久伴 提交于 2020-01-11 14:17:12

问题


This question is based on the thread.

I have the shell function

function man()
{       
    man "$1" > /tmp/manual; less /tmp/manual 
}

The problem is there exists the command man.

How can you replace the command with my command?


回答1:


Replace man "$1" with the pathname: /usr/bin/man. Or change it to use 'which man' within backquotes. Then run your script in the current shell. On bash/ksh you need to save your script in some file, say man.sh and then run it as '. ./man.sh'.

cat > man.sh
function man()
{       
    /usr/bin/man "$1" > /tmp/manual; less /tmp/manual 
}
^D

. ./man.sh

You get the idea. You can undefine the function at any time: unset -f man



来源:https://stackoverflow.com/questions/1053707/unable-to-unbind-a-shell-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!