Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: =?utf-8?Q?Lawrence_Vel=C3=A1zquez?= Newsgroups: gnu.bash.bug Subject: Re: Return from function depending on number of parameters Date: Fri, 3 Jul 2020 17:39:52 -0400 Lines: 32 Approved: bug-bash@gnu.org Message-ID: References: <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1593812399 13040 209.51.188.17 (3 Jul 2020 21:39:59 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: Chris Elvidge Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=larryv.me; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm3; bh=q sKEe2OH8/MQ8AeEQlkp8rLwBM3neHne6ckpR872ljA=; b=Xnfmamei3M+ciA0iP Ppr0Ryc3J4OsMOOJHA2X9ntn9MLWKeBrMoW/IKLuh/TSfJgRpIuGw01eLk/JkKpi eGSOzEqsD2+AHZXWz2k601G32CWft/311U0RFulwPdRsI7BuzxbPkK7N9+0+Ux3O jROWNuGwiLlh5aEReyMxRqbskLtLh15XeDdrgU0jFieuvzvY/YCmVPKb9biJcDoU q5cw+o1dvDHWp+sTcv9Z4FrptPn8lCUYFgV2yVtQoE9oUraSQ9QSUxtG4znafful GbZl+pYsjbNPOzgJxnfWwhCvENo9HNaygIWdxnuj5ZjNCF4xYiYV7cjf7ATipbK6 4OU2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=qsKEe2OH8/MQ8AeEQlkp8rLwBM3neHne6ckpR872l jA=; b=X+l0CJXFme2K6qXUE0swZDu8H6z9mroSahiV9ZDYcwVOsVWDeAXWS//4v W6ICsDQPV7eldQEQmM1oyv0lzAFfE1buo+llBcjNnzpGm2hCNKD6jso+Vf2Lkc0h jlHWgyeAvIKzSieKENdy0fcvnWlPi2F3NKo4qvJp4zxKy2WjUBy25Vk9fjwDHxX2 7V0HTh0r6YQjEshd2hk+6VHzExxdfUmHsiQub3/BxNlktPdmeJTUoy/DxWYeWpO+ vnCMjGbXZMV76M+lPrPy2jgDIK6meHUJqgyJ9lQm2UmXFJwwZDRQ05n3WtnNB6Ov 76w8OJV/HN1xjC2LvU36cAdtcEQdg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrtdejgddtudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpegtggfuhfgjfffgkfhfvffosehtjehmtdhhtddvnecuhfhrohhmpefnrgifrhgv nhgtvggpgggvlhojiihquhgviicuoehvqheslhgrrhhrhihvrdhmvgeqnecuggftrfgrth htvghrnhepudektdevhedvveevheetkeehieelgeefgeehgeejuefguddtffdvudegleei ieejnecukfhppedutddtrdduvddrudekgedrvdegieenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehvqheslhgrrhhrhihvrdhmvg X-ME-Proxy: In-Reply-To: X-Mailer: Apple Mail (2.3445.104.14) Received-SPF: pass client-ip=64.147.123.19; envelope-from=vq@larryv.me; helo=wout3-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/03 16:52:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me> X-Mailman-Original-References: Xref: csiph.com gnu.bash.bug:16530 > On Jul 3, 2020, at 2:00 PM, Chris Elvidge wrote: > > However 'N=0; echo $((!$N))' gives an error at the bash prompt. > 'echo $[!$N]' echo's 1 as expected. > > My question - is $[...] actually obsolete? It might tell you something that $[...] is not even mentioned in the man page for bash 3.2.57, which is decidedly not the current version. > If so, what should I use at the bash prompt to get the same effect? I expect that the error you encountered was caused by !$ expanding to the last word of the previous command and making the contents of $((...)) an invalid arithmetic expression. This didn't affect your scripts because history expansion is not enabled in non-interactive shells by default. Try inserting a space. $ N=0; printf %s\\n "$((! $N))" 1 You can even drop the $. $ N=0; printf %s\\n "$((! N))" 1 vq