Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
number of arguments zargs use
- X-seq: zsh-workers 20532
- From: Motoi Washida <a66@xxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: number of arguments zargs use
- Date: Sat, 30 Oct 2004 22:59:08 +0900
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Hi all,
I use zargs. It is good when I want to use long arguments. But it uses 
too small number of arguments at a time for me.
This tries to get size of arguments allowed. I don't know this is 
portable enough, but it seems to work for me.
Index: zargs
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Misc/zargs,v
retrieving revision 1.3
diff -d -u -r1.3 zargs
--- zargs	4 Sep 2002 06:28:37 -0000	1.3
+++ zargs	30 Oct 2004 13:54:47 -0000
@@ -213,7 +213,21 @@
     fi
 fi
-s=${${s##-(s|-max-chars(=|))}:-20480}
+s=${s##-(s|-max-chars(=|))}
+
+if (( !s ))
+then
+    local argmax envvars
+    argmax="$({command getconf ARG_MAX ||
+	command sysctl -n kern.argmax} 2>/dev/null)"
+    if (( argmax ))
+    then
+        envvars="$(builtin typeset -x)"
+        s=$(( argmax - ( ${#${(f)envvars}} + ${#envvars} + 2048 ) ))
+    else
+        s=-20480
+    fi
+fi
 l=${${l##-(l|-max-lines(=|))}:-${${l[1]:+1}:-$ARGC}}
 # Everything has to be in a subshell just in case of backgrounding 
jobs,
--
Motoi Washida
Messages sorted by:
Reverse Date,
Date,
Thread,
Author