开发者

select function in bash

开发者 https://www.devze.com 2023-02-06 01:06 出处:网络
I want to define a shell-function named \"select\" (can you guess what I want it for?). This is tricky because select is a shell-builtin.

I want to define a shell-function named "select" (can you guess what I want it for?). This is tricky because select is a shell-builtin.

I have tried something this:

function select() {
  echo "select"
}

but when I try it on the command-line I get this error:

bash: syntax error near unexpected token `newline'

I have tried to turn the builtin off, but to no avail:

> enable -n select
bash: enable: select: not a shell builtin

So my 开发者_开发百科question is: How can I define a bash-function named "select"?

Many thanks!


That is a bash reserved word, so you will not be able to define any function with that name. Your error is because bash expects the rest of the normal select construction


why can't you choose another name? select is reserved for bash.

function Select(){
 echo "select"
}
0

精彩评论

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

关注公众号