* Bug in shell.el: explicit-bash-args does not work for bash 1.x
@ 2002-10-25 14:28 Kim F. Storm
2002-10-26 20:13 ` Richard Stallman
0 siblings, 1 reply; 14+ messages in thread
From: Kim F. Storm @ 2002-10-25 14:28 UTC (permalink / raw)
Cc: emacs-devel
It is quite a mystery to me why I just started to get bitten by the
follow change [which is now 4 month old]:
2002-06-28 Andreas Schwab <schwab@suse.de>
* shell.el (explicit-bash-args): New user option.
This is specified to define explicit-bash-args to --noediting -i
which are the proper options for bash 2.x
However, for bash 1.x (included with e.g. redhat 6.2), the --noediting
option isn't recognized and bash refuses to start.
For bash 1.x, the corresponding option was named -nolineediting, but
even setting that option doesn't really work, as (for some reason I
don't understand) process-send-eof is then unable to terminate the
running bash 1.x (so C-d at EOB no longer exits the shell)!
Only reverting back to explicit-bash-args not including neither
--noediting nor -nolineediting makes it work ok.
As I said above, I'm puzzled why I didn't discover this earlier -- I
use shell buffers all the time, but maybe it's been some time since I
actually did that on the system where I still have redhat 6.2
installed.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-25 14:28 Bug in shell.el: explicit-bash-args does not work for bash 1.x Kim F. Storm
@ 2002-10-26 20:13 ` Richard Stallman
2002-10-27 0:17 ` Kim F. Storm
0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2002-10-26 20:13 UTC (permalink / raw)
Cc: schwab, emacs-devel
However, for bash 1.x (included with e.g. redhat 6.2), the --noediting
option isn't recognized and bash refuses to start.
That is fairly old. I don't think we should drop the feature
just for the sake of old systems. Is there a way to detect the
error and start bash again in a suitable way for bash 1.x?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-26 20:13 ` Richard Stallman
@ 2002-10-27 0:17 ` Kim F. Storm
2002-10-28 19:19 ` Richard Stallman
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Kim F. Storm @ 2002-10-27 0:17 UTC (permalink / raw)
Cc: schwab, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> However, for bash 1.x (included with e.g. redhat 6.2), the --noediting
> option isn't recognized and bash refuses to start.
>
> That is fairly old. I don't think we should drop the feature
> just for the sake of old systems. Is there a way to detect the
> error and start bash again in a suitable way for bash 1.x?
>
The following code returns the proper setting for bash 1.x and 2.x.
I suppose it could be used as the initial value for explicit-bash-args.
(let* ((prog (or (and (boundp 'explicit-shell-file-name) explicit-shell-file-name)
(getenv "ESHELL") shell-file-name))
(name (file-name-nondirectory prog)))
(if (and (equal name "bash")
(file-executable-p prog)
(string-match "bad option"
(shell-command-to-string (concat prog " --noediting"))))
'("-i")
'("--noediting" "-i")))
It is optimized to run (when shell.el is loaded) only if the
configured shell is actually bash, meaning that it isn't set properly
if the user later changes from some other shell to bash after loading
shell.el.
If that behaviour is not acceptable, we can check for bash explicitly
and set the option unconditionally:
(if (string-match "bad option"
(shell-command-to-string "/bin/bash --noediting"))
'("-i")
'("--noediting" "-i"))
However, that assumes that bash 1.x is located in /bin/bash for the
proper [reduced] setting is selected -- probably a reasonable
assumption, and still not much harm done if it makes the wrong
choice.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-27 0:17 ` Kim F. Storm
@ 2002-10-28 19:19 ` Richard Stallman
2002-10-28 21:48 ` Stefan Monnier
2002-11-01 0:38 ` Kim F. Storm
2 siblings, 0 replies; 14+ messages in thread
From: Richard Stallman @ 2002-10-28 19:19 UTC (permalink / raw)
Cc: schwab, emacs-devel
The following code returns the proper setting for bash 1.x and 2.x.
I suppose it could be used as the initial value for explicit-bash-args.
It looks reasonable to me--unless someone finds ways to improve it,
please install it.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-27 0:17 ` Kim F. Storm
2002-10-28 19:19 ` Richard Stallman
@ 2002-10-28 21:48 ` Stefan Monnier
2002-10-28 23:29 ` Kim F. Storm
` (3 more replies)
2002-11-01 0:38 ` Kim F. Storm
2 siblings, 4 replies; 14+ messages in thread
From: Stefan Monnier @ 2002-10-28 21:48 UTC (permalink / raw)
Cc: rms, schwab, emacs-devel
> (let* ((prog (or (and (boundp 'explicit-shell-file-name) explicit-shell-file-name)
> (getenv "ESHELL") shell-file-name))
> (name (file-name-nondirectory prog)))
> (if (and (equal name "bash")
> (file-executable-p prog)
> (string-match "bad option"
> (shell-command-to-string (concat prog " --noediting"))))
> '("-i")
> '("--noediting" "-i")))
I must say I don't like the idea of running a program when loadng
a .el file. It's already done at various places, tho.
There is no strong reason, but one of the recent problem I came
across in this area is that process operations don't work properly during
dumping (the handling of sigchld is explicitly not turned on because
it can supposedly prevent unexec from working right).
That prevents byte-compiling ediff with temacs, for example, because
ediff runs `patch' (IIRC) while loading one of its .el files.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-28 21:48 ` Stefan Monnier
@ 2002-10-28 23:29 ` Kim F. Storm
2002-10-29 6:17 ` Eli Zaretskii
2002-10-29 6:15 ` Eli Zaretskii
` (2 subsequent siblings)
3 siblings, 1 reply; 14+ messages in thread
From: Kim F. Storm @ 2002-10-28 23:29 UTC (permalink / raw)
Cc: rms, schwab, emacs-devel
"Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:
> > (let* ((prog (or (and (boundp 'explicit-shell-file-name) explicit-shell-file-name)
> > (getenv "ESHELL") shell-file-name))
> > (name (file-name-nondirectory prog)))
> > (if (and (equal name "bash")
> > (file-executable-p prog)
> > (string-match "bad option"
> > (shell-command-to-string (concat prog " --noediting"))))
> > '("-i")
> > '("--noediting" "-i")))
>
> I must say I don't like the idea of running a program when loadng
> a .el file. It's already done at various places, tho.
>
> There is no strong reason, but one of the recent problem I came
> across in this area is that process operations don't work properly during
> dumping (the handling of sigchld is explicitly not turned on because
> it can supposedly prevent unexec from working right).
>
The following code doesn't execute the program; it does a brute-force
check for the version of the bash program by looking inside the
executeable. This works for me on GNU/Linux -- again, if it
doesn't work on other platforms, it doesn't do any worse than
the current default...
(let* ((prog (or (and (boundp 'explicit-shell-file-name) explicit-shell-file-name)
(getenv "ESHELL") shell-file-name))
(name (file-name-nondirectory prog)))
(if (and (equal name "bash")
(file-executable-p prog)
(file-readable-p prog)
(with-temp-buffer
(insert-file-contents-literally prog)
(goto-char (point-min))
(search-forward "@(#)Bash version 1" nil t)))
'("-i")
'("--noediting" "-i")))
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-28 21:48 ` Stefan Monnier
2002-10-28 23:29 ` Kim F. Storm
@ 2002-10-29 6:15 ` Eli Zaretskii
2002-10-29 14:42 ` Stefan Monnier
2002-10-29 7:40 ` Kai Großjohann
2002-10-29 11:29 ` Richard Stallman
3 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2002-10-29 6:15 UTC (permalink / raw)
Cc: emacs-devel
On Mon, 28 Oct 2002, Stefan Monnier wrote:
> There is no strong reason, but one of the recent problem I came
> across in this area is that process operations don't work properly during
> dumping (the handling of sigchld is explicitly not turned on because
> it can supposedly prevent unexec from working right).
>
> That prevents byte-compiling ediff with temacs, for example, because
> ediff runs `patch' (IIRC) while loading one of its .el files.
Perhaps there's a need for some new `eval-*' form that would not run at
dump time?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-28 23:29 ` Kim F. Storm
@ 2002-10-29 6:17 ` Eli Zaretskii
0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2002-10-29 6:17 UTC (permalink / raw)
Cc: emacs-devel
On 29 Oct 2002, Kim F. Storm wrote:
> The following code doesn't execute the program; it does a brute-force
> check for the version of the bash program by looking inside the
> executeable.
I think this is very non-portable and should be avoided at all costs.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-28 21:48 ` Stefan Monnier
2002-10-28 23:29 ` Kim F. Storm
2002-10-29 6:15 ` Eli Zaretskii
@ 2002-10-29 7:40 ` Kai Großjohann
2002-10-30 21:32 ` Kim F. Storm
2002-10-29 11:29 ` Richard Stallman
3 siblings, 1 reply; 14+ messages in thread
From: Kai Großjohann @ 2002-10-29 7:40 UTC (permalink / raw)
"Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:
> I must say I don't like the idea of running a program when loadng
> a .el file. It's already done at various places, tho.
Yes. How about starting bash with one set of args, if that fails try
the other set of args? I think it's not much of a problem to start
bash twice instead of once (if the first try fails).
kai
--
~/.signature is: umop ap!sdn (Frank Nobis)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-28 21:48 ` Stefan Monnier
` (2 preceding siblings ...)
2002-10-29 7:40 ` Kai Großjohann
@ 2002-10-29 11:29 ` Richard Stallman
3 siblings, 0 replies; 14+ messages in thread
From: Richard Stallman @ 2002-10-29 11:29 UTC (permalink / raw)
Cc: storm, schwab, emacs-devel
There is no strong reason, but one of the recent problem I came
across in this area is that process operations don't work properly during
dumping (the handling of sigchld is explicitly not turned on because
it can supposedly prevent unexec from working right).
That prevents byte-compiling ediff with temacs, for example, because
ediff runs `patch' (IIRC) while loading one of its .el files.
There can be a conditional to avoid running the program
if purify-flag is non-nil.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-29 6:15 ` Eli Zaretskii
@ 2002-10-29 14:42 ` Stefan Monnier
0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2002-10-29 14:42 UTC (permalink / raw)
Cc: Stefan Monnier, emacs-devel
> > There is no strong reason, but one of the recent problem I came
> > across in this area is that process operations don't work properly during
> > dumping (the handling of sigchld is explicitly not turned on because
> > it can supposedly prevent unexec from working right).
> >
> > That prevents byte-compiling ediff with temacs, for example, because
> > ediff runs `patch' (IIRC) while loading one of its .el files.
>
> Perhaps there's a need for some new `eval-*' form that would not run at
> dump time?
Why bother: you can already test `purify-flag'.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-29 7:40 ` Kai Großjohann
@ 2002-10-30 21:32 ` Kim F. Storm
2002-10-31 6:33 ` Kai Großjohann
0 siblings, 1 reply; 14+ messages in thread
From: Kim F. Storm @ 2002-10-30 21:32 UTC (permalink / raw)
Cc: emacs-devel
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
> "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:
>
> > I must say I don't like the idea of running a program when loadng
> > a .el file. It's already done at various places, tho.
>
> Yes. How about starting bash with one set of args, if that fails try
> the other set of args? I think it's not much of a problem to start
> bash twice instead of once (if the first try fails).
It could be done, but as proposed, this requires special treatment
of bash in M-x shell.
Maybe we could have explicit-SHELL-args-2 which is an alternate
set of args to use in case the shell fails to start with the
args provided in explicit-SHELL-args.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-30 21:32 ` Kim F. Storm
@ 2002-10-31 6:33 ` Kai Großjohann
0 siblings, 0 replies; 14+ messages in thread
From: Kai Großjohann @ 2002-10-31 6:33 UTC (permalink / raw)
Cc: emacs-devel
storm@cua.dk (Kim F. Storm) writes:
> Maybe we could have explicit-SHELL-args-2 which is an alternate
> set of args to use in case the shell fails to start with the
> args provided in explicit-SHELL-args.
Yes, or explicit-SHELL-args could be a vector of lists of strings if
multiple tries are necessary.
kai
--
~/.signature is: umop ap!sdn (Frank Nobis)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x
2002-10-27 0:17 ` Kim F. Storm
2002-10-28 19:19 ` Richard Stallman
2002-10-28 21:48 ` Stefan Monnier
@ 2002-11-01 0:38 ` Kim F. Storm
2 siblings, 0 replies; 14+ messages in thread
From: Kim F. Storm @ 2002-11-01 0:38 UTC (permalink / raw)
Cc: schwab, emacs-devel
storm@cua.dk (Kim F. Storm) writes:
> The following code returns the proper setting for bash 1.x and 2.x.
>
> I suppose it could be used as the initial value for explicit-bash-args.
>
>
> (let* ((prog (or (and (boundp 'explicit-shell-file-name) explicit-shell-file-name)
> (getenv "ESHELL") shell-file-name))
> (name (file-name-nondirectory prog)))
> (if (and (equal name "bash")
> (file-executable-p prog)
> (string-match "bad option"
> (shell-command-to-string (concat prog " --noediting"))))
> '("-i")
> '("--noediting" "-i")))
>
I added a check for (not purify-flag) to the above and installed it.
It works nicely on my GNU/Linux platforms (mixture of Bash 1.x and 2.x).
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2002-11-01 0:38 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-25 14:28 Bug in shell.el: explicit-bash-args does not work for bash 1.x Kim F. Storm
2002-10-26 20:13 ` Richard Stallman
2002-10-27 0:17 ` Kim F. Storm
2002-10-28 19:19 ` Richard Stallman
2002-10-28 21:48 ` Stefan Monnier
2002-10-28 23:29 ` Kim F. Storm
2002-10-29 6:17 ` Eli Zaretskii
2002-10-29 6:15 ` Eli Zaretskii
2002-10-29 14:42 ` Stefan Monnier
2002-10-29 7:40 ` Kai Großjohann
2002-10-30 21:32 ` Kim F. Storm
2002-10-31 6:33 ` Kai Großjohann
2002-10-29 11:29 ` Richard Stallman
2002-11-01 0:38 ` Kim F. Storm
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).