Does the system-wide limit on argument count apply in shell functions?

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











up vote
2
down vote

favorite












The other question asks about the limit on building up commands by find's -exec ... +. Here I'd like to know how those limits compare to shells' inner limits. Do they mimic system limits or are they independent? What are they?



I'm a Bash user, but will learn of any Unix and Linux shells if only out of curiosity.










share|improve this question



























    up vote
    2
    down vote

    favorite












    The other question asks about the limit on building up commands by find's -exec ... +. Here I'd like to know how those limits compare to shells' inner limits. Do they mimic system limits or are they independent? What are they?



    I'm a Bash user, but will learn of any Unix and Linux shells if only out of curiosity.










    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      The other question asks about the limit on building up commands by find's -exec ... +. Here I'd like to know how those limits compare to shells' inner limits. Do they mimic system limits or are they independent? What are they?



      I'm a Bash user, but will learn of any Unix and Linux shells if only out of curiosity.










      share|improve this question















      The other question asks about the limit on building up commands by find's -exec ... +. Here I'd like to know how those limits compare to shells' inner limits. Do they mimic system limits or are they independent? What are they?



      I'm a Bash user, but will learn of any Unix and Linux shells if only out of curiosity.







      shell function arguments






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 6 hours ago

























      asked 6 hours ago









      Tomasz

      8,70052761




      8,70052761




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted











          Does the system-wide limit on argument count apply in shell functions?




          No, that's a limit on the execve() system call used by processes to execute a different executable to replace the current one. That does not apply to functions which are interpreted by the current shell interpreter in the same process. That also doesn't apply to built-in utilities.



          execve() wipes the memory of the process before loading and starting the new executable. The whole point of functions and builtins is for that not to happen so the function can modify the variables and other parameters of the shell, so they will typically not use execve().




          Do they mimic system limits




          No.




          or are they independent?




          Yes.




          What are they?




          As much as the resource limits for the current shell process allows.



          The bash manual says:



          There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously.



          This seem to apply, since function arguments are an internal shell array (not passed to the exec kernel function).



          Historically, ksh88 and pdksh had a low limit on array indices, but not on number of function arguments. You could only access $1, ... $9 directly in the Bourne shell, but you could still pass as many arguments as you'd like to functions and for instance loop over all of them with for arg do... or pass them along to another function or builtin with "$@".






          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: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            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%2f481163%2fdoes-the-system-wide-limit-on-argument-count-apply-in-shell-functions%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
            3
            down vote



            accepted











            Does the system-wide limit on argument count apply in shell functions?




            No, that's a limit on the execve() system call used by processes to execute a different executable to replace the current one. That does not apply to functions which are interpreted by the current shell interpreter in the same process. That also doesn't apply to built-in utilities.



            execve() wipes the memory of the process before loading and starting the new executable. The whole point of functions and builtins is for that not to happen so the function can modify the variables and other parameters of the shell, so they will typically not use execve().




            Do they mimic system limits




            No.




            or are they independent?




            Yes.




            What are they?




            As much as the resource limits for the current shell process allows.



            The bash manual says:



            There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously.



            This seem to apply, since function arguments are an internal shell array (not passed to the exec kernel function).



            Historically, ksh88 and pdksh had a low limit on array indices, but not on number of function arguments. You could only access $1, ... $9 directly in the Bourne shell, but you could still pass as many arguments as you'd like to functions and for instance loop over all of them with for arg do... or pass them along to another function or builtin with "$@".






            share|improve this answer


























              up vote
              3
              down vote



              accepted











              Does the system-wide limit on argument count apply in shell functions?




              No, that's a limit on the execve() system call used by processes to execute a different executable to replace the current one. That does not apply to functions which are interpreted by the current shell interpreter in the same process. That also doesn't apply to built-in utilities.



              execve() wipes the memory of the process before loading and starting the new executable. The whole point of functions and builtins is for that not to happen so the function can modify the variables and other parameters of the shell, so they will typically not use execve().




              Do they mimic system limits




              No.




              or are they independent?




              Yes.




              What are they?




              As much as the resource limits for the current shell process allows.



              The bash manual says:



              There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously.



              This seem to apply, since function arguments are an internal shell array (not passed to the exec kernel function).



              Historically, ksh88 and pdksh had a low limit on array indices, but not on number of function arguments. You could only access $1, ... $9 directly in the Bourne shell, but you could still pass as many arguments as you'd like to functions and for instance loop over all of them with for arg do... or pass them along to another function or builtin with "$@".






              share|improve this answer
























                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted







                Does the system-wide limit on argument count apply in shell functions?




                No, that's a limit on the execve() system call used by processes to execute a different executable to replace the current one. That does not apply to functions which are interpreted by the current shell interpreter in the same process. That also doesn't apply to built-in utilities.



                execve() wipes the memory of the process before loading and starting the new executable. The whole point of functions and builtins is for that not to happen so the function can modify the variables and other parameters of the shell, so they will typically not use execve().




                Do they mimic system limits




                No.




                or are they independent?




                Yes.




                What are they?




                As much as the resource limits for the current shell process allows.



                The bash manual says:



                There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously.



                This seem to apply, since function arguments are an internal shell array (not passed to the exec kernel function).



                Historically, ksh88 and pdksh had a low limit on array indices, but not on number of function arguments. You could only access $1, ... $9 directly in the Bourne shell, but you could still pass as many arguments as you'd like to functions and for instance loop over all of them with for arg do... or pass them along to another function or builtin with "$@".






                share|improve this answer















                Does the system-wide limit on argument count apply in shell functions?




                No, that's a limit on the execve() system call used by processes to execute a different executable to replace the current one. That does not apply to functions which are interpreted by the current shell interpreter in the same process. That also doesn't apply to built-in utilities.



                execve() wipes the memory of the process before loading and starting the new executable. The whole point of functions and builtins is for that not to happen so the function can modify the variables and other parameters of the shell, so they will typically not use execve().




                Do they mimic system limits




                No.




                or are they independent?




                Yes.




                What are they?




                As much as the resource limits for the current shell process allows.



                The bash manual says:



                There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously.



                This seem to apply, since function arguments are an internal shell array (not passed to the exec kernel function).



                Historically, ksh88 and pdksh had a low limit on array indices, but not on number of function arguments. You could only access $1, ... $9 directly in the Bourne shell, but you could still pass as many arguments as you'd like to functions and for instance loop over all of them with for arg do... or pass them along to another function or builtin with "$@".







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 5 hours ago


























                community wiki





                5 revs, 4 users 86%
                Isaac




























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481163%2fdoes-the-system-wide-limit-on-argument-count-apply-in-shell-functions%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?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay