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












2














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





























    2














    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



























      2












      2








      2







      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 Nov 11 '18 at 23:03

























      asked Nov 11 '18 at 22:35









      Tomasz

      9,19352965




      9,19352965






















          1 Answer
          1






          active

          oldest

          votes


















          3















          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',
            autoActivateHeartbeat: false,
            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















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3















            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




























              3















              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


























                3












                3








                3







                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 Nov 11 '18 at 23:53


























                community wiki





                5 revs, 4 users 86%
                Isaac































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    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















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Full-time equivalent

                    さくらももこ

                    13 indicted, 8 arrested in Calif. drug cartel investigation