Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15274 > unrolled thread

Re: ulimit call lists invalid options

Started byRobert Elz <kre@munnari.OZ.AU>
First post2019-07-30 12:09 +0700
Last post2019-07-30 12:09 +0700
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: ulimit call lists invalid options Robert Elz <kre@munnari.OZ.AU> - 2019-07-30 12:09 +0700

#15274 — Re: ulimit call lists invalid options

FromRobert Elz <kre@munnari.OZ.AU>
Date2019-07-30 12:09 +0700
SubjectRe: ulimit call lists invalid options
Message-ID<mailman.225.1564463449.1985.bug-bash@gnu.org>
The ulimit usage lists all the limits that bash supports.
Of those, the ones that actually work are the ones that your
system also supports.

On my system (like yours) ulimit -P and ulimit -k fail, as
while the system has pseudo tty's and kqueues, there are no
per process limits on how many can be allocated.

On the other hand:
	ulimit -T
	1024
	ulimit -b 
	unlimited

Further, when I rewrite your script into more rational shell
code (it is still not portable, and cannot be, as the format
of error messages is almost never defined ... different shells
produce different kinds of error messages) [modified script below]
I get:

jinx$ bash /tmp/S
ops=bcdefiklmnpqrstuvxPT
/tmp/S: line 14: ulimit: -e: invalid option
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
/tmp/S: line 14: ulimit: -i: invalid option
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
/tmp/S: line 14: ulimit: -k: invalid option
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
/tmp/S: line 14: ulimit: -q: invalid option
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
/tmp/S: line 14: ulimit: -r: invalid option
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
/tmp/S: line 14: ulimit: -x: invalid option
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
/tmp/S: line 14: ulimit: -P: invalid option
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]

so there are a whole lot more options (limits) supported on
your system than mine.

Whether bash ought limit its usage output option list to those
options supported on the system it is running on, or whether it
is better to list everything it knows about (either my, or your,
system might have more limits bash knows nothing about) is a
judgement call - neither answer will be right for everyone.

kre

The modified script (using shell idioms, rather that
whatever language you were trying to emulate):

ops=$(ulimit -h 2>&1)
ops=${ops#*\[-SHa}
ops=${ops%%]*}

printf ops=%s\\n "$ops"

while [ -n "$ops" ]
do
	rest=${ops#?}
	op=${ops%${rest}}
	ops=$rest

	ulimit "-$op" >/dev/null
done 2>&1


[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web