unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: emacs-devel@gnu.org
Subject: Re: sh-script.el and magic numbers
Date: Mon, 20 Jan 2003 18:45:02 -0600 (CST)	[thread overview]
Message-ID: <200301210045.SAA16966@eel.dms.auburn.edu> (raw)
In-Reply-To: <200301200759.h0K7xGOH007624@beta.mvs.co.il> (ehud@unix.mvs.co.il)

Ehud Karni wrote:

   The solution to that is simple. Don't put the "#!" magic number,
   instead change the 1st line to something like this:
   # <your comment> -*- mode: sh -*-

In certain situations it can get somewhat less simple.   

There is a problem here that is still relevant, even though (actually
especially since) a decision has been made on the #! problem.  A
problem I referred to but did not elaborate on, because I thought
(like you) that it could trivially be solved with file local variables
is, in fact, not really as easily solved (for people not familiar with
the sh-script.el source code) as I thought.

Please remember in the following that people could be experienced
shell programmers and even experienced Emacs users without knowing any
Elisp beyond routine customization.

Suppose your default sh-shell-file is bash and are working on a script
intended for csh.  You do not want to use a magic number and maybe do
not want to make the file executable, but you still want all of
sh-script.el to know that you are programming for csh.

The problem is that C-c : will not allow to change sh-shell-file
without inserting a magic number.  Somebody familiar with the
sh-script.el source code can get around this by executing, say 
M-: (sh-set-shell "/bin/csh"), but this is not mentioned in the mode
documentation.  It is also does not persist through different Emacs
sessions, anyway.  Do not try to add .csh or similar to the file name,
it is going to be ignored.  So obviously we try file local variables:

# <your comment> -*- mode: sh; sh-shell-file: /bin/csh; -*-  

Does not work.  sh-shell-file gets set after sh-mode has ran.  The
mode line still says [bash] and indeed, just try, for instance: 
C-c C-c, you get bash's version of case, not csh's switch.  What you 
have to do is:

# <your comment> -*- mode: sh; eval: (sh-set-shell "/bin/csh"); -*-

So it probably would be useful to mention in the mode documentation
that, to tell sh-mode the shell you are programming for, without using
a magic number, you have to do something like 
M-: (sh-set-shell "/bin/csh")
if you want it on a temporary basis and (probably more relevantly),
you have to put something like the previously mentioned line at the
beginning of the script, if you want it to persist.  There still is
the problem that enable-local-eval has to be non-nil (t or maybe) for
the line to work.  I do not know what to do about that.  At least, the
value does not need to be t.  One could, of course, make clear that
using a magic number is way simpler and, in nearly all situations,
vastly preferable.

Sincerely,

Luc.

  reply	other threads:[~2003-01-21  0:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-19  3:24 sh-script.el and magic numbers Luc Teirlinck
2003-01-19 12:47 ` Ehud Karni
2003-01-19 23:48   ` Glenn Morris
2003-01-20  7:59     ` Ehud Karni
2003-01-21  0:45       ` Luc Teirlinck [this message]
2003-01-21 10:49         ` Glenn Morris
2003-01-21 15:30           ` Luc Teirlinck
2003-01-21 15:44             ` Glenn Morris
2003-01-21 16:04               ` Luc Teirlinck
2003-01-21 17:23               ` Luc Teirlinck
2003-01-21 23:51                 ` Luc Teirlinck
2003-01-23  8:00                   ` Richard Stallman
2003-01-22  0:26                 ` Luc Teirlinck
2003-01-21 16:54           ` Kai Großjohann
2003-01-21 19:29             ` Luc Teirlinck
2003-01-21 20:00               ` Kai Großjohann
2003-01-22  8:41               ` Kai Großjohann
2003-01-22 14:18                 ` Luc Teirlinck
2003-01-22 20:51                   ` Luc Teirlinck
2003-01-23  1:12                   ` Kevin Rodgers
2003-01-20 16:45   ` Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=200301210045.SAA16966@eel.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    --cc=emacs-devel@gnu.org \
    /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.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).