* 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
* Re: number of arguments zargs use
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
0 siblings, 2 replies; 4+ messages in thread
From: Bart Schaefer @ 2004-10-31 5:30 UTC (permalink / raw)
To: Motoi Washida; +Cc: zsh-workers
On Sat, 30 Oct 2004, Motoi Washida wrote:
> This tries to get size of arguments allowed. I don't know this is
> portable enough, but it seems to work for me.
This set me off wandering down the road to Obfuscatory ...
s=${${s##-(s|-max-chars(=|))}:-$(((s=$({command getconf ARG_MAX ||
command sysctl -n kern.argmax || echo 0} 2>/dev/null))?
(s-=${#$(builtin typeset +x)}+2048):20480))}
That would be equivalent to, though significantly less readable than,
your patch, except that there is a bug in your patch:
> + else
> + s=-20480
> + fi
That should be "s=20480", not -20480. You'd never want a negative number
of characters.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: number of arguments zargs use
2004-10-31 5:30 ` Bart Schaefer
@ 2004-10-31 7:34 ` Motoi Washida
2004-11-04 1:32 ` Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: Motoi Washida @ 2004-10-31 7:34 UTC (permalink / raw)
To: zsh-workers
Hi Bart,
> This set me off wandering down the road to Obfuscatory ...
>
> s=${${s##-(s|-max-chars(=|))}:-$(((s=$({command getconf ARG_MAX ||
> command sysctl -n kern.argmax || echo 0} 2>/dev/null))?
> (s-=${#$(builtin typeset +x)}+2048):20480))}
I don't mind which way is used.
>> + else
>> + s=-20480
>> + fi
Opps, sorry.
Thanks!
--
Motoi Washida
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: number of arguments zargs use
2004-10-31 5:30 ` Bart Schaefer
2004-10-31 7:34 ` Motoi Washida
@ 2004-11-04 1:32 ` Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2004-11-04 1:32 UTC (permalink / raw)
To: zsh-workers
On Sat, 30 Oct 2004, Bart Schaefer wrote:
> s=${${s##-(s|-max-chars(=|))}:-$(((s=$({command getconf ARG_MAX ||
> command sysctl -n kern.argmax || echo 0} 2>/dev/null))?
> (s-=${#$(builtin typeset +x)}+2048):20480))}
Just in case anyone tries this, there's a typo: +x should be -x.
^ 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).