help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] What affects the number of arguments allowed?


From: Peng Yu
Subject: [Help-bash] What affects the number of arguments allowed?
Date: Mon, 10 Dec 2018 19:47:38 -0600

Hi,

The following test case runs differently on different terminals
(tested on Mac OS X). Sometimes, it fails sometimes, it does not.

Somebody says it is determined by kern.argmax Mac OS X. There are
obviously other factors affecting the limit.

https://stackoverflow.com/questions/43305775/osx-sierra-argument-list-too-long

How does bash determine this limit? Is there a command that one can
predetermine what is a legitimate length instead of trying it and
fails?

$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

for i in $(seq 100000)
do
    eval "x$i=$i"
done
set -v
for n in $(seq 18941 18942)
do
    echo "==> $n <=="
    x=$(seq "$n")
    echo "${#x}"
    ./script.sh $(seq "$n")
done
$ ./main.sh
for n in $(seq 18941 18942)
do
    echo "==> $n <=="
    x=$(seq "$n")
    echo "${#x}"
    ./script.sh $(seq "$n")
done
==> 18941 <==
102539
==> 18942 <==
102545
./main.sh: line 14: ./script.sh: Argument list too long


-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]