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

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question















  • 1




    [[ 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










  • Note that [ is a builltin command in bash. Presumably it was added to the shell for performance.
    – glenn jackman
    May 9 at 21:50














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.







share|improve this question















  • 1




    [[ 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










  • Note that [ is a builltin command in bash. Presumably it was added to the shell for performance.
    – glenn jackman
    May 9 at 21:50












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.







share|improve this question











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.









share|improve this question










share|improve this question




share|improve this question









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 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












  • 1




    [[ 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










  • 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










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.






share|improve this answer





















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    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






























    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.






    share|improve this answer

























      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.






      share|improve this answer























        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.






        share|improve this answer













        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.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered May 9 at 20:32









        Hauke Laging

        53.2k1282130




        53.2k1282130






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            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













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)