Can I view Bash POSIX extensions?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-2
down vote

favorite












I'm reading about the bash shell and I've read from many sources that to make bash POSIX compliant it needs "extensions". Which sounds to me like something I should be able to load or unload into bash. I've tried googling the subject but can't seem to find any detail about this subject. What little I can find basically says nothing more than "Bash needs extensions".



Is there a way I can view the extensions Bash is loading? Load or unload them? Configure them differently?







share|improve this question






















  • This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
    – ilkkachu
    Jan 13 at 20:09















up vote
-2
down vote

favorite












I'm reading about the bash shell and I've read from many sources that to make bash POSIX compliant it needs "extensions". Which sounds to me like something I should be able to load or unload into bash. I've tried googling the subject but can't seem to find any detail about this subject. What little I can find basically says nothing more than "Bash needs extensions".



Is there a way I can view the extensions Bash is loading? Load or unload them? Configure them differently?







share|improve this question






















  • This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
    – ilkkachu
    Jan 13 at 20:09













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I'm reading about the bash shell and I've read from many sources that to make bash POSIX compliant it needs "extensions". Which sounds to me like something I should be able to load or unload into bash. I've tried googling the subject but can't seem to find any detail about this subject. What little I can find basically says nothing more than "Bash needs extensions".



Is there a way I can view the extensions Bash is loading? Load or unload them? Configure them differently?







share|improve this question














I'm reading about the bash shell and I've read from many sources that to make bash POSIX compliant it needs "extensions". Which sounds to me like something I should be able to load or unload into bash. I've tried googling the subject but can't seem to find any detail about this subject. What little I can find basically says nothing more than "Bash needs extensions".



Is there a way I can view the extensions Bash is loading? Load or unload them? Configure them differently?









share|improve this question













share|improve this question




share|improve this question








edited Jan 13 at 20:07









jimmij

28.9k867100




28.9k867100










asked Jan 13 at 19:38









Bodisha

232




232











  • This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
    – ilkkachu
    Jan 13 at 20:09

















  • This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
    – ilkkachu
    Jan 13 at 20:09
















This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
– ilkkachu
Jan 13 at 20:09





This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
– ilkkachu
Jan 13 at 20:09











2 Answers
2






active

oldest

votes

















up vote
4
down vote













Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.



Those extensions include things like the [[ test syntax, a,b,c brace expansion, variable indirection with $!x, process substitution with <(...), and history expansion with !. The extensions are the non-POSIX parts of Bash, in this sense.



They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash if, for example, it uses the ! character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:



foo() ... ; 
x=1 foo
echo $x


In POSIX sh, that should output "1", but run with bash the assignment to x doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.




Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time executable runs instead in some cases:



$ time --help
bash: --help: command not found
$ set -o posix
$ time --help
Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]


There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[ and $!x, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.




There are other shells, notably dash, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.






share|improve this answer



























    up vote
    0
    down vote













    There are three different ways to force bash to be POSIX compliant.



    • Start bash with --posix option

    • Set option posix while bash is already running: set -o posix


    • Use environment variable POSIXLY_CORRECT:




      If this variable is in the environment when bash starts, the shell
      enters posix mode before reading the startup files, as if the --posix invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the command set -o posix had been executed.




    Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.






    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%2f416893%2fcan-i-view-bash-posix-extensions%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      4
      down vote













      Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.



      Those extensions include things like the [[ test syntax, a,b,c brace expansion, variable indirection with $!x, process substitution with <(...), and history expansion with !. The extensions are the non-POSIX parts of Bash, in this sense.



      They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash if, for example, it uses the ! character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:



      foo() ... ; 
      x=1 foo
      echo $x


      In POSIX sh, that should output "1", but run with bash the assignment to x doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.




      Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time executable runs instead in some cases:



      $ time --help
      bash: --help: command not found
      $ set -o posix
      $ time --help
      Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]


      There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[ and $!x, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.




      There are other shells, notably dash, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.






      share|improve this answer
























        up vote
        4
        down vote













        Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.



        Those extensions include things like the [[ test syntax, a,b,c brace expansion, variable indirection with $!x, process substitution with <(...), and history expansion with !. The extensions are the non-POSIX parts of Bash, in this sense.



        They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash if, for example, it uses the ! character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:



        foo() ... ; 
        x=1 foo
        echo $x


        In POSIX sh, that should output "1", but run with bash the assignment to x doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.




        Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time executable runs instead in some cases:



        $ time --help
        bash: --help: command not found
        $ set -o posix
        $ time --help
        Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]


        There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[ and $!x, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.




        There are other shells, notably dash, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.






        share|improve this answer






















          up vote
          4
          down vote










          up vote
          4
          down vote









          Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.



          Those extensions include things like the [[ test syntax, a,b,c brace expansion, variable indirection with $!x, process substitution with <(...), and history expansion with !. The extensions are the non-POSIX parts of Bash, in this sense.



          They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash if, for example, it uses the ! character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:



          foo() ... ; 
          x=1 foo
          echo $x


          In POSIX sh, that should output "1", but run with bash the assignment to x doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.




          Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time executable runs instead in some cases:



          $ time --help
          bash: --help: command not found
          $ set -o posix
          $ time --help
          Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]


          There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[ and $!x, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.




          There are other shells, notably dash, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.






          share|improve this answer












          Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.



          Those extensions include things like the [[ test syntax, a,b,c brace expansion, variable indirection with $!x, process substitution with <(...), and history expansion with !. The extensions are the non-POSIX parts of Bash, in this sense.



          They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash if, for example, it uses the ! character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:



          foo() ... ; 
          x=1 foo
          echo $x


          In POSIX sh, that should output "1", but run with bash the assignment to x doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.




          Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time executable runs instead in some cases:



          $ time --help
          bash: --help: command not found
          $ set -o posix
          $ time --help
          Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]


          There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[ and $!x, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.




          There are other shells, notably dash, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 13 at 20:05









          Michael Homer

          42.5k6108148




          42.5k6108148






















              up vote
              0
              down vote













              There are three different ways to force bash to be POSIX compliant.



              • Start bash with --posix option

              • Set option posix while bash is already running: set -o posix


              • Use environment variable POSIXLY_CORRECT:




                If this variable is in the environment when bash starts, the shell
                enters posix mode before reading the startup files, as if the --posix invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the command set -o posix had been executed.




              Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.






              share|improve this answer
























                up vote
                0
                down vote













                There are three different ways to force bash to be POSIX compliant.



                • Start bash with --posix option

                • Set option posix while bash is already running: set -o posix


                • Use environment variable POSIXLY_CORRECT:




                  If this variable is in the environment when bash starts, the shell
                  enters posix mode before reading the startup files, as if the --posix invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the command set -o posix had been executed.




                Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  There are three different ways to force bash to be POSIX compliant.



                  • Start bash with --posix option

                  • Set option posix while bash is already running: set -o posix


                  • Use environment variable POSIXLY_CORRECT:




                    If this variable is in the environment when bash starts, the shell
                    enters posix mode before reading the startup files, as if the --posix invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the command set -o posix had been executed.




                  Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.






                  share|improve this answer












                  There are three different ways to force bash to be POSIX compliant.



                  • Start bash with --posix option

                  • Set option posix while bash is already running: set -o posix


                  • Use environment variable POSIXLY_CORRECT:




                    If this variable is in the environment when bash starts, the shell
                    enters posix mode before reading the startup files, as if the --posix invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the command set -o posix had been executed.




                  Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 13 at 20:05









                  jimmij

                  28.9k867100




                  28.9k867100






















                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416893%2fcan-i-view-bash-posix-extensions%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?