zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk, 339635-forwarded@bugs.debian.org
Subject: Re: [ramk@cse.iitm.ernet.in: Bug#339635: zsh: zsh-mime-handler used even in the case of executable files]
Date: Wed, 5 Apr 2006 11:14:28 +0100	[thread overview]
Message-ID: <20060405111428.2902ee9f.pws@csr.com> (raw)

Clint Adams <schizo@debian.org> wrote:
> From: "R.Ramkumar" <ramk@cse.iitm.ernet.in>
> 
> Some scripts end with a .sh (a common example being autogen.sh). For
> such scripts, zsh-mime-handler ends up executing the mime action for
> the suffix sh, which sometimes happens to be to just display the
> file. This, I guess is due to alias -s, which blindly maps in case
> the suffix matches. To counter this, it would be good if
> zsh-mime-handler uses a style to take a set of patterns that would
> be executed as-is, despite having a suffix found in the mime
> configuration. I am enclosing a patch for the same. I have made the
> set of executable files as the default for this style, I hope this
> deviation from the original behaviour is acceptable.

The change from the original behaviour seems sensible.

I'll commit this with the following documentation.  I've also turned $@
into "$@" in zsh-mime-handler.

Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.55
diff -u -r1.55 contrib.yo
--- Doc/Zsh/contrib.yo	20 Mar 2006 11:06:25 -0000	1.55
+++ Doc/Zsh/contrib.yo	5 Apr 2006 10:12:20 -0000
@@ -1391,6 +1391,15 @@
 tt(sh) process.  This is more efficient, but may not work in the occasional
 cases where the mailcap handler uses strict POSIX syntax.
 )
+item(tt(execute-as-is))(
+This style gives a list of patterns to be matched against files
+passed for execution with a handler program.  If the file matches
+the pattern, the entire command line is executed in its current form,
+with no handler.  This is useful for files which might have suffixes
+but nonetheless be executable in their own right.  If the style
+is not set, the pattern tt(*+LPAR()*+RPAR()) is used; hence executable
+files are executed directly and not passed to a handler.
+)
 item(tt(flags))(
 Defines flags to go with a handler; the context is as for the
 tt(handler) style, and the format is as for the flags in tt(mailcap).
Index: Functions/MIME/zsh-mime-handler
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/MIME/zsh-mime-handler,v
retrieving revision 1.4
diff -u -r1.4 zsh-mime-handler
--- Functions/MIME/zsh-mime-handler	28 Feb 2006 11:57:20 -0000	1.4
+++ Functions/MIME/zsh-mime-handler	5 Apr 2006 10:12:20 -0000
@@ -45,6 +45,22 @@
 context=":mime:.${suffix}:"
 
 local handler flags no_sh no_bg
+local -a exec_asis
+
+# Set to a list of patterns which are ignored and executed as they are,
+# despite being called for interpretation by the mime handler.
+# Defaults to executable files, which ensures that they are executed as
+# they are, even if they have a suffix.
+zstyle -a $context execute-as-is exec_asis || exec_asis=('*(*)')
+
+local pattern
+
+for pattern in $exec_asis; do
+    if [[ $1 = ${~pattern} ]]; then
+	"$@"
+	return 0
+    fi
+done
 
 zstyle -s $context handler handler ||
   handler="${zsh_mime_handlers[$suffix]}"

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


             reply	other threads:[~2006-04-05 10:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-05 10:14 Peter Stephenson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-04-06 13:07 Peter Stephenson
2006-03-31 14:22 Clint Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060405111428.2902ee9f.pws@csr.com \
    --to=pws@csr.com \
    --cc=339635-forwarded@bugs.debian.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).