From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5900 invoked from network); 10 Feb 2021 06:05:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Feb 2021 06:05:46 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1612937146; b=Laqz3y+R8qDUsuo3CSKJZZyPJRhL3H75NAIGlpxv7HdinBkj/ENCID8auMamrLP3BX16apg+N/ WhB7KAlZj77OCmXSig6jWE3erm5VkQS7O6ZorNSKm8S/uDcpu5cp3fd4AhifhUqrK3OTUv4rVP 4pYR+aA0SVhUohudTF7L2Sjavf84Lo1s5KqnW4ujWifcHEpJWnciqHb1FAdolqRjwrDLm2Zhf9 oiHpVQ7bk1qh4fmVsbpvHahhXly1TOz6WoRZyZMkHrfq0qVwwEs/AL1+o26KQR8h6R4vx1kzQo B95Ge0GsT5QFkME8HfR7L2cMUDh3dx0ynQF8SZjIQOt16w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oo1-f50.google.com) smtp.remote-ip=209.85.161.50; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1612937146; bh=Vpu6KOHBV2pXBhauDOLsc5jKEDEq/gAZyi2AdnFhfPE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=1AAJCree1DdBzUD2WSaHmPz7PMqFUA6OQpChG3oGrBznu7TbrPAVN/RJA6Hu+lpDfmmP71d83L 3YAwPFTrsBH3EKkrctBLGSXWLAd6j7bJ5vQHyeLLXATQMRf+5WNbqPA+oWIxEgfPQq/Sx07caM Dl9va6IdDtn6AP+m6jX4tbnsAR0QZ3HYfZJAbtyTVSlSQ087KEy+jgWiAO9NgEID7JE9xh9sg4 0lnbqFJpPmZkA0TyzgkUmVCy+yhn+RNt6pgBsAG8AKbwoNOdqLqck4e/ocka6BvRzHMMrT94vJ LlVLgQcjlrpqKD78oeElbpml+kviSfubZSi4BE8WqGsm1g==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=oCJbuKMnBXxMr2cRIeZpEC8LN5nfjTCuQLH2+KYLgpU=; b=1gH4lvINcvSSET3Ki1GDrwBl+L ejpzmKqGRaqWsz88wMN8hbGSyl3kPWQZYyTM/X8T7iBcn4fpoZchDg0cLTXGcUmvY2Ekxbd4KX5NC McHPB6HlCY8mqg1WK0Wfis1dmOnTbEnQLnXTw1XzzUTiHvMTXWlvuOTkGhrCoGeQPcpIhcLORxc2i efMlNQOi8Ovn0l/C0tnWuRgTqQfoykTG2NVk8n+nwd6vE5OdN87+szDvOK26L+PjDsfpZglsQbv22 By7OFGKHHFKWIGvmSAX806rojDrrYZigpTsT+pgoORyg7Z2pJuhKbmbT5j32dqNw2y1F+8eQkWrrn m6VUCZCg==; Received: from authenticated user by zero.zsh.org with local id 1l9idC-000Glv-P3; Wed, 10 Feb 2021 06:05:42 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oo1-f50.google.com) smtp.remote-ip=209.85.161.50; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oo1-f50.google.com ([209.85.161.50]:37097) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1l9icw-000GdQ-PS; Wed, 10 Feb 2021 06:05:27 +0000 Received: by mail-oo1-f50.google.com with SMTP id e17so267725oow.4 for ; Tue, 09 Feb 2021 22:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=oCJbuKMnBXxMr2cRIeZpEC8LN5nfjTCuQLH2+KYLgpU=; b=cFaHxwoKBnBefDvWA79vmNe+baUUs693S08/sSaBCaoQ6+PpyaEsIS8o/ns04qwxer kqrAp6SH3hAraYiS7SMCGr681p1MRPnVKdwcwsYNzLMbJkHmc8LXT5ldeht3jbJMG7ay ocIYtE4FB4YnjJjCBNnkJ93m/yVRvCYLVYtx3L9EJpAaOQryL1i+EwIMrjYDwox0y+gB q4vc5BetxEc7iRVaLVHRPMq3AL3x4Y3AL5sDBNL3bTUWxYPJdxr95Y8ThLIMJP5kP0w2 5UjQoLzpElP7pTyNjz4agWGLod+wbZfBGEyYjNN+FUR/mqX2iEDLulnCk6bas5Wfwqlq 7jlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=oCJbuKMnBXxMr2cRIeZpEC8LN5nfjTCuQLH2+KYLgpU=; b=tYDlYLY2wruPF1Ze6qZtbNIQ7uRwPzbBHLOfqbFJXIUkmdfciO310M7VKVWG9r8QE0 QxinTCS8nlrKVlPQ0pYfHhTHVAzj69ir6BGK6qIR/WXEPJzxXOEC1nMB88LZxWmb3vOY /Lv+91SGR6V1RJSY+2HY3sTUQ4yu+zBKmYXaExr18/sfEoATN5DUHdDk+v9nnYH1Z9XS loBlOFrEoazGxxLIg/UsuToi8tq4sQtA4rL2umcW7je1WszcIdOWNWZdeB9BNr4pqXP1 GMYhWYUE2Ayj/vCgPNKz7P9fZFX6Fk7g3uoMQeOXnYakdj3BdbPJmWzbeVooQtPY8kwS LnVw== X-Gm-Message-State: AOAM532ZNeLI9PcojJ7V/FUQWHB4cq1gsW1SgXhYG0+ip/ayViStvADc npvmnKkFjk1yyHqteeSDGLchnqcNoJ0BxsSogEie85hUe6gOHA== X-Google-Smtp-Source: ABdhPJwFJwW643TszE1c1lgyC/JH6n4R2mfpE2yfPIIH1GP0Jnn3I/GXT37p7wo69P8R09cOoXzltAS7O5ujdrCKG04= X-Received: by 2002:a4a:b1c4:: with SMTP id j4mr1103914ooo.78.1612937124714; Tue, 09 Feb 2021 22:05:24 -0800 (PST) MIME-Version: 1.0 From: Bart Schaefer Date: Tue, 9 Feb 2021 22:05:13 -0800 Message-ID: Subject: Block comments ala Ray To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47991 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: I've been noodling around with Ray Andrew's oft-repeated suggestion of some kind of block comment syntax. After considerable prodding of gettok() in lex.c, I came up with something that works like this: A line beginning with !# introduces a block comment. This (deliberately) means that NO_BANG_HIST must be in effect, so without some hoop-jumping this only affects scripts. I chose this because it seems unlikely to me that anyone would write in a script !# this is just a silly way to mean false The comment ends after a line containing #! anywhere in the line. So a full block could be: !# This begins a block comment. This is merely rambling. This #! is the last line of the block Stylistically, of course, I'd recommend putting the #! either at the beginning or the end of that third line, but tokenizing worked best just consuming everything up through the newline once #! was recognized. I experimented with allowing the block comment to start or end in the middle of lines, but it was just too weird to be able to do print this !# part is a comment but this part #! is not a comment (which would print "this is not a comment"), and a solo "!" out of command position may not be as rare as one at the start of a line. I tried some other character combinations ... for example I can't find any circumstance in which it is not a syntax error to write <# so if it's appealing to match that with #> for symmetry, it's a small edit. But I wasn't happy that those appear to be redirections. Having told you all that ... there's one glitch with my implementation. To detect whether !# is at the beginning of a line, in gettok() I test the "isnewlin" boolean. This works everywhere (that I've found) except when on the first character of a new script file. That means you can't begin a script with a block comment ... which perhaps is a good thing, since typo-ing "!#/bin/sh" may not be all that uncommon, and having the entire script turn into a comment would be a bit startling. However, I would like to know what (if anything) can be tested to identify the first character of a new script? I've tried combinations of of isnewlin -- this is initialized to false isfirstch -- this is true after any separator isfirstln -- true throughout any single-line command What else could be examined? Any other thoughts about this? Too horrible to consider? It needs turning off in emulation modes and I haven't gotten to that yet.