Bash: Is '[[' also a program like '['?

Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
The test condition [ is a program, which is residing on debian based distributions in /usr/bin/[. I would like to know if the other condition tester [[ is also a program?
The reason why I am asking: I granted sudo rights to a certain user to let him trigger a shell script. As for security reasons I'm adding the full path to each program (echo to /bin/echo and [ to /usr/bin/[) used in that script, so that the user could not change his PATH to use his own programs. Now I'm wondering if I have to change [[, too.
linux bash test
add a comment |Â
up vote
4
down vote
favorite
The test condition [ is a program, which is residing on debian based distributions in /usr/bin/[. I would like to know if the other condition tester [[ is also a program?
The reason why I am asking: I granted sudo rights to a certain user to let him trigger a shell script. As for security reasons I'm adding the full path to each program (echo to /bin/echo and [ to /usr/bin/[) used in that script, so that the user could not change his PATH to use his own programs. Now I'm wondering if I have to change [[, too.
linux bash test
1
[[is a keyword. Related: askubuntu.com/a/590335
â Jesse_b
May 9 at 20:30
You say: "I grantedsudorights to a certain user to let him trigger a shell script. "... So shouldn't you only add the path to that shell script to sudoers instead???
â Filipe Brandenburger
May 9 at 21:00
Note that[is a builltin command in bash. Presumably it was added to the shell for performance.
â glenn jackman
May 9 at 21:50
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
The test condition [ is a program, which is residing on debian based distributions in /usr/bin/[. I would like to know if the other condition tester [[ is also a program?
The reason why I am asking: I granted sudo rights to a certain user to let him trigger a shell script. As for security reasons I'm adding the full path to each program (echo to /bin/echo and [ to /usr/bin/[) used in that script, so that the user could not change his PATH to use his own programs. Now I'm wondering if I have to change [[, too.
linux bash test
The test condition [ is a program, which is residing on debian based distributions in /usr/bin/[. I would like to know if the other condition tester [[ is also a program?
The reason why I am asking: I granted sudo rights to a certain user to let him trigger a shell script. As for security reasons I'm adding the full path to each program (echo to /bin/echo and [ to /usr/bin/[) used in that script, so that the user could not change his PATH to use his own programs. Now I'm wondering if I have to change [[, too.
linux bash test
asked May 9 at 20:24
chevallier
8251116
8251116
1
[[is a keyword. Related: askubuntu.com/a/590335
â Jesse_b
May 9 at 20:30
You say: "I grantedsudorights to a certain user to let him trigger a shell script. "... So shouldn't you only add the path to that shell script to sudoers instead???
â Filipe Brandenburger
May 9 at 21:00
Note that[is a builltin command in bash. Presumably it was added to the shell for performance.
â glenn jackman
May 9 at 21:50
add a comment |Â
1
[[is a keyword. Related: askubuntu.com/a/590335
â Jesse_b
May 9 at 20:30
You say: "I grantedsudorights to a certain user to let him trigger a shell script. "... So shouldn't you only add the path to that shell script to sudoers instead???
â Filipe Brandenburger
May 9 at 21:00
Note that[is a builltin command in bash. Presumably it was added to the shell for performance.
â glenn jackman
May 9 at 21:50
1
1
[[ is a keyword. Related: askubuntu.com/a/590335â Jesse_b
May 9 at 20:30
[[ is a keyword. Related: askubuntu.com/a/590335â Jesse_b
May 9 at 20:30
You say: "I granted
sudo rights to a certain user to let him trigger a shell script. "... So shouldn't you only add the path to that shell script to sudoers instead???â Filipe Brandenburger
May 9 at 21:00
You say: "I granted
sudo rights to a certain user to let him trigger a shell script. "... So shouldn't you only add the path to that shell script to sudoers instead???â Filipe Brandenburger
May 9 at 21:00
Note that
[ is a builltin command in bash. Presumably it was added to the shell for performance.â glenn jackman
May 9 at 21:50
Note that
[ is a builltin command in bash. Presumably it was added to the shell for performance.â glenn jackman
May 9 at 21:50
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
man bash
RESERVED WORDS
Reserved words are words that have a special meaning to the shell. The following words are recognized as reserved when unquoted and either the first word of a simple command (see SHELL GRAMMAR below) or the third word of a case or for command:
! case coproc do done elif else esac fi for function if in select then until while time [[ ]]
So [[ is a reserved word and thus cannot be an external command. There might be such a file, though, but it would have to be called with the full path or with quotes.
And even if there was such an external command then it would not work the same way because [[ as part of the shell grammar changes the parsing rules until the next ]]. External commands cannot do that.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
man bash
RESERVED WORDS
Reserved words are words that have a special meaning to the shell. The following words are recognized as reserved when unquoted and either the first word of a simple command (see SHELL GRAMMAR below) or the third word of a case or for command:
! case coproc do done elif else esac fi for function if in select then until while time [[ ]]
So [[ is a reserved word and thus cannot be an external command. There might be such a file, though, but it would have to be called with the full path or with quotes.
And even if there was such an external command then it would not work the same way because [[ as part of the shell grammar changes the parsing rules until the next ]]. External commands cannot do that.
add a comment |Â
up vote
5
down vote
accepted
man bash
RESERVED WORDS
Reserved words are words that have a special meaning to the shell. The following words are recognized as reserved when unquoted and either the first word of a simple command (see SHELL GRAMMAR below) or the third word of a case or for command:
! case coproc do done elif else esac fi for function if in select then until while time [[ ]]
So [[ is a reserved word and thus cannot be an external command. There might be such a file, though, but it would have to be called with the full path or with quotes.
And even if there was such an external command then it would not work the same way because [[ as part of the shell grammar changes the parsing rules until the next ]]. External commands cannot do that.
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
man bash
RESERVED WORDS
Reserved words are words that have a special meaning to the shell. The following words are recognized as reserved when unquoted and either the first word of a simple command (see SHELL GRAMMAR below) or the third word of a case or for command:
! case coproc do done elif else esac fi for function if in select then until while time [[ ]]
So [[ is a reserved word and thus cannot be an external command. There might be such a file, though, but it would have to be called with the full path or with quotes.
And even if there was such an external command then it would not work the same way because [[ as part of the shell grammar changes the parsing rules until the next ]]. External commands cannot do that.
man bash
RESERVED WORDS
Reserved words are words that have a special meaning to the shell. The following words are recognized as reserved when unquoted and either the first word of a simple command (see SHELL GRAMMAR below) or the third word of a case or for command:
! case coproc do done elif else esac fi for function if in select then until while time [[ ]]
So [[ is a reserved word and thus cannot be an external command. There might be such a file, though, but it would have to be called with the full path or with quotes.
And even if there was such an external command then it would not work the same way because [[ as part of the shell grammar changes the parsing rules until the next ]]. External commands cannot do that.
answered May 9 at 20:32
Hauke Laging
53.2k1282130
53.2k1282130
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442857%2fbash-is-also-a-program-like%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
[[is a keyword. Related: askubuntu.com/a/590335â Jesse_b
May 9 at 20:30
You say: "I granted
sudorights to a certain user to let him trigger a shell script. "... So shouldn't you only add the path to that shell script to sudoers instead???â Filipe Brandenburger
May 9 at 21:00
Note that
[is a builltin command in bash. Presumably it was added to the shell for performance.â glenn jackman
May 9 at 21:50