Bourne | Shells | whatshell |  #!  | Ash | find | ARG_MAX | portability | permissions | UUOC | ancient | - | ../Various | HOME
"$@" | echo | tty defs | tty chars | $() vs ) | IFS | using siginfo | nanosleep | line charset | locale


This is an extract from a GNU autoconf configure script:
if test "X$1" = X--fallback-echo; then
  # used as fallback echo
  shift
  cat <<EOF
$*
EOF
  exit $EXIT_SUCCESS
fi

# [...]

i=0
testring="ABCD"
new_result=

# If test is not a shell built-in, we'll probably end up computing a
# maximum length that is only half of the actual maximum length, but
# we can't tell.
while (test "X"`$SHELL $0 --fallback-echo "X$testring" 2>/dev/null` \
           = "XX$testring") >/dev/null 2>&1 &&
        new_result=`expr "X$testring" : ".*" 2>&1` &&
        max_cmd_len="$new_result" &&
        test "$i" != 17 # 1/2 MB should be enough
do
  i=`expr $i + 1`
  testring="$testring$testring"
done
testring=
# Add a significant safety factor because C++ compilers can tack on massive
# amounts of additional arguments before passing them to the linker.
# It appears as though 1/2 is a usable value.
max_cmd_len=`expr $max_cmd_len \/ 2`