Discussion:
[Help-bash] why bash shows the same error for both too many arguments or an argument that is too long?
Peng Yu
2016-10-28 20:22:45 UTC
Permalink
Hi,

The following two commands show the same error message. But for the
first command, there is only one argument. Is there error message
incorrect? Also, why bash fails for the first case. Is there any
restriction on the length of a single argument?

~$ "$(type -P echo)" "$(seq 100000)"
-bash: /usr/local/opt/coreutils/libexec/gnubin/echo: Argument list too long
~$ "$(type -P echo)" $(seq 100000)
-bash: /usr/local/opt/coreutils/libexec/gnubin/echo: Argument list too long
--
Regards,
Peng
Greg Wooledge
2016-10-28 20:29:49 UTC
Permalink
Post by Peng Yu
~$ "$(type -P echo)" "$(seq 100000)"
-bash: /usr/local/opt/coreutils/libexec/gnubin/echo: Argument list too long
~$ "$(type -P echo)" $(seq 100000)
-bash: /usr/local/opt/coreutils/libexec/gnubin/echo: Argument list too long
First of all, this error is coming from the kernel, not from the shell.
Even though it says -bash at the beginning, the limitation is one in
your operating system, not in bash.

http://www.in-ulm.de/~mascheck/various/argmax/ is an excellent reference
for this subject.
Post by Peng Yu
The following two commands show the same error message. But for the
first command, there is only one argument. Is there error message
incorrect? Also, why bash fails for the first case. Is there any
restriction on the length of a single argument?
The restriction is on the total length (in bytes) of the argument list,
not the number of arguments.

Loading...