From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28892 invoked by alias); 10 Nov 2017 18:50:22 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42002 Received: (qmail 17457 invoked by uid 1010); 10 Nov 2017 18:50:21 -0000 X-Qmail-Scanner-Diagnostics: from kahlil.inlv.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(37.59.109.123):SA:0(-1.9/5.0):. Processed in 4.545604 secs); 10 Nov 2017 18:50:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: martijn@inlv.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | To: Zsh hackers list From: Martijn Dekker Subject: [PATCH] don't exit shell on [[ -o invalid@option ]] Message-ID: <0d6faa9a-fb69-8343-9630-a60d8f1bee0a@inlv.org> Date: Fri, 10 Nov 2017 18:24:29 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------E589534BD8C445782B3A0FAD" Content-Language: en-GB --------------E589534BD8C445782B3A0FAD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Does it make sense for [[ -o invalid@option ]] to exit the shell with an error message? Other shells with '[[' (bash, ksh93 and pdksh/mksh variants) quietly return an unsuccessful status for a non-existent shell option. That behaviour makes more sense to me because of: (1) backwards compatibility: a script that uses '[[' to test if a shell option introduced in a recent zsh is set, would still work on an older zsh that doesn't have that shell option. (2) cross-shell compatibility: treating a non-existent option as not set would make it easier to write a script that works on bash, ksh93, and pdksh/mksh as well as zsh. The attached patch brings zsh in line with those other shells. Up to you to decide what to do with it... - Martijn --------------E589534BD8C445782B3A0FAD Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="dont-exit-on-testing-invalid-option.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="dont-exit-on-testing-invalid-option.patch" ZGlmZiAtLWdpdCBhL1NyYy9jb25kLmMgYi9TcmMvY29uZC5jCmluZGV4IGI5YTQ3Y2UuLjVl YjU5YjIgMTAwNjQ0Ci0tLSBhL1NyYy9jb25kLmMKKysrIGIvU3JjL2NvbmQuYwpAQCAtNDky LDcgKzQ5Miw3IEBAIGRvbHN0YXQoY2hhciAqcykKIAogCiAvKgotICogb3B0aXNvbiByZXR1 cm5zIGV2YWxjb25kLWZyaWVuZGx5IHN0YXR1c2VzICh0cnVlLCBmYWxzZSwgZXJyb3IpLgor ICogb3B0aXNvbiByZXR1cm5zIGV2YWxjb25kLWZyaWVuZGx5IHN0YXR1c2VzICh0cnVlLCBm YWxzZSkuCiAgKi8KIAogLyoqLwpAQCAtNTA2LDggKzUwNiw3IEBAIG9wdGlzb24oY2hhciAq bmFtZSwgY2hhciAqcykKICAgICBlbHNlCiAJaSA9IG9wdGxvb2t1cChzKTsKICAgICBpZiAo IWkpIHsKLQl6d2Fybm5hbShuYW1lLCAibm8gc3VjaCBvcHRpb246ICVzIiwgcyk7Ci0JcmV0 dXJuIDI7CisJcmV0dXJuIDE7CiAgICAgfSBlbHNlIGlmKGkgPCAwKQogCXJldHVybiAhdW5z ZXQoLWkpOwogICAgIGVsc2UK --------------E589534BD8C445782B3A0FAD--