Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Robert Elz Newsgroups: gnu.bash.bug Subject: Re: ulimit call lists invalid options Date: Tue, 30 Jul 2019 12:09:34 +0700 Lines: 68 Approved: bug-bash@gnu.org Message-ID: References: <5D3FB223.5000601@tlinx.org> <23361.1564463374@jinx.noi.kre.to> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1564463450 13449 209.51.188.17 (30 Jul 2019 05:10:50 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: L A Walsh Envelope-to: bug-bash@gnu.org In-Reply-To: <5D3FB223.5000601@tlinx.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 2001:3c8:9009:181::2 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <23361.1564463374@jinx.noi.kre.to> X-Mailman-Original-References: <5D3FB223.5000601@tlinx.org> Xref: csiph.com gnu.bash.bug:15274 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