Does the system-wide limit on argument count apply in shell functions?
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
add a comment |
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
add a comment |
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
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
shell function arguments
edited Nov 11 '18 at 23:03
asked Nov 11 '18 at 22:35
Tomasz
9,19352965
9,19352965
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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 "$@"
.
add a comment |
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
});
}
});
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
Required, but never shown
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
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 "$@"
.
add a comment |
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 "$@"
.
add a comment |
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 "$@"
.
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 "$@"
.
edited Nov 11 '18 at 23:53
community wiki
5 revs, 4 users 86%
Isaac
add a comment |
add a comment |
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.
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
Required, but never shown
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
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
Required, but never shown
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
Required, but never shown
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
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