zsh-workers
 help / color / mirror / code / Atom feed
* number of arguments zargs use
@ 2004-10-30 13:59 Motoi Washida
  2004-10-31  5:30 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Motoi Washida @ 2004-10-30 13:59 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-04  1:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-30 13:59 number of arguments zargs use Motoi Washida
2004-10-31  5:30 ` Bart Schaefer
2004-10-31  7:34   ` Motoi Washida
2004-11-04  1:32   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).