unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Make the shell location configurable
@ 2017-08-14 22:36 Robert Ewald
  2017-08-15 13:53 ` Tomi Ollila
  2017-08-15 16:02 ` David Bremner
  0 siblings, 2 replies; 11+ messages in thread
From: Robert Ewald @ 2017-08-14 22:36 UTC (permalink / raw)
  To: notmuch; +Cc: Robert Ewald

The location of the shell is not always /bin/sh. Use the
shell-file-name variable to be able to specify the shell location.
---
 emacs/notmuch-lib.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 337b20ac..8dffe9f2 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -921,7 +921,7 @@ status."
 	 (command (or (executable-find notmuch-command)
 		      (error "command not found: %s" notmuch-command)))
 	 (proc (apply #'start-process name buffer
-		      "/bin/sh" "-c"
+		      shell-file-name "-c"
 		      "exec 2>\"$1\"; shift; exec \"$0\" \"$@\""
 		      command err-file args)))
     (process-put proc 'err-file err-file)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-14 22:36 [PATCH] emacs: Make the shell location configurable Robert Ewald
@ 2017-08-15 13:53 ` Tomi Ollila
  2017-08-15 16:02 ` David Bremner
  1 sibling, 0 replies; 11+ messages in thread
From: Tomi Ollila @ 2017-08-15 13:53 UTC (permalink / raw)
  To: Robert Ewald, notmuch

On Tue, Aug 15 2017, Robert Ewald wrote:

> The location of the shell is not always /bin/sh. Use the
> shell-file-name variable to be able to specify the shell location.
> ---
>  emacs/notmuch-lib.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 337b20ac..8dffe9f2 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -921,7 +921,7 @@ status."
>  	 (command (or (executable-find notmuch-command)
>  		      (error "command not found: %s" notmuch-command)))
>  	 (proc (apply #'start-process name buffer
> -		      "/bin/sh" "-c"
> +		      shell-file-name "-c"
>  		      "exec 2>\"$1\"; shift; exec \"$0\" \"$@\""
>  		      command err-file args)))
>      (process-put proc 'err-file err-file)

I don't yet know a (unix) system where /bin/sh did not provide a bourne
compatible shell that supports the syntax used above.

My shell-file-name expands to "/bin/zsh". I wonder if it expanded like
"/usr/bin/tcsh" or "/path/to/fish" or "/path/to/rc" those worked here.


Tomi


> -- 
> 2.11.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-14 22:36 [PATCH] emacs: Make the shell location configurable Robert Ewald
  2017-08-15 13:53 ` Tomi Ollila
@ 2017-08-15 16:02 ` David Bremner
  2017-08-15 20:04   ` Robert Ewald
  1 sibling, 1 reply; 11+ messages in thread
From: David Bremner @ 2017-08-15 16:02 UTC (permalink / raw)
  To: Robert Ewald, notmuch

Robert Ewald <robewald@gmx.net> writes:

> The location of the shell is not always /bin/sh. Use the
> shell-file-name variable to be able to specify the shell location.
> ---

Can you say a bit more about the problem you are trying to solve? I
think shell-file-name is not guaranteed to be Bourne shell compatible.

d

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-15 16:02 ` David Bremner
@ 2017-08-15 20:04   ` Robert Ewald
  2017-08-15 23:38     ` David Bremner
  0 siblings, 1 reply; 11+ messages in thread
From: Robert Ewald @ 2017-08-15 20:04 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch

Hello,

Thanks for reviewing the patch.

> On 15 Aug 2017, at 18:02, David Bremner <david@tethera.net> wrote:
> 
> Robert Ewald <robewald@gmx.net> writes:
> 
>> The location of the shell is not always /bin/sh. Use the
>> shell-file-name variable to be able to specify the shell location.
>> ---
> 
> Can you say a bit more about the problem you are trying to solve? I
> think shell-file-name is not guaranteed to be Bourne shell compatible.

I would like to use notmuch with a remote-notmuch script on emacs on 
windows (not cygwin).

Right now I cannot make this work, because that version of emacs doesn't 
have any kind of unix style paths. I have an installation of msys that 
provides the usual unix tools. This is configured in the init.el by
setting shell-file-name.

Does the shell-file-name have to be bourne shell compatible? My
understanding is that using "/bin/sh" requires a POSIX compatible shell, 
bash specific shell scripts should be invoked with e.g. /bin/bash.
I believe a POSIX compatible shell is sufficient in this particular case. 
Of course, if shell-file-name is not POSIX compatible this line may not 
work.

Another way would be to introduce another configuration variable, but I 
would like to avoid that.

Best regards

Robert

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-15 20:04   ` Robert Ewald
@ 2017-08-15 23:38     ` David Bremner
  2017-08-16  7:17       ` Robert Ewald
  0 siblings, 1 reply; 11+ messages in thread
From: David Bremner @ 2017-08-15 23:38 UTC (permalink / raw)
  To: Robert Ewald; +Cc: notmuch

Robert Ewald <robewald@gmx.net> writes:

> Does the shell-file-name have to be bourne shell compatible? My
> understanding is that using "/bin/sh" requires a POSIX compatible shell, 
> bash specific shell scripts should be invoked with e.g. /bin/bash.
> I believe a POSIX compatible shell is sufficient in this particular case. 
> Of course, if shell-file-name is not POSIX compatible this line may not 
> work.

Yeah, I was sloppy. Hopefully POSIX compatibility is enough (if not we
can probably fix that). But as you note there's no guarantee
shell-file-name is POSIX compatible.

d

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-15 23:38     ` David Bremner
@ 2017-08-16  7:17       ` Robert Ewald
  2017-08-16 11:09         ` David Bremner
  0 siblings, 1 reply; 11+ messages in thread
From: Robert Ewald @ 2017-08-16  7:17 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch


> On 16 Aug 2017, at 01:38, David Bremner <david@tethera.net> wrote:
> 
> Robert Ewald <robewald@gmx.net> writes:
> 
>> Does the shell-file-name have to be bourne shell compatible? My
>> understanding is that using "/bin/sh" requires a POSIX compatible shell, 
>> bash specific shell scripts should be invoked with e.g. /bin/bash.
>> I believe a POSIX compatible shell is sufficient in this particular case. 
>> Of course, if shell-file-name is not POSIX compatible this line may not 
>> work.
> 
> Yeah, I was sloppy. Hopefully POSIX compatibility is enough (if not we
> can probably fix that). But as you note there's no guarantee
> shell-file-name is POSIX compatible.
> 
> d

I did some research: apparently shell-file-name should be POSIX compatible,
otherwise many plugins don't work. explicit-shell-file-name however can be set to
fish or tcsh if you want to use that in M-x shell.

https://emacs.stackexchange.com/questions/28647/how-do-i-change-the-default-shell-for-shell-command

So I think the patch as submitted is good, please apply.

Thanks.

Robert.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-16  7:17       ` Robert Ewald
@ 2017-08-16 11:09         ` David Bremner
  2017-08-16 20:16           ` Robert Ewald
  0 siblings, 1 reply; 11+ messages in thread
From: David Bremner @ 2017-08-16 11:09 UTC (permalink / raw)
  To: Robert Ewald; +Cc: notmuch

Robert Ewald <robewald@gmx.net> writes:

>> On 16 Aug 2017, at 01:38, David Bremner <david@tethera.net> wrote:

> I did some research: apparently shell-file-name should be POSIX compatible,
> otherwise many plugins don't work. explicit-shell-file-name however can be set to
> fish or tcsh if you want to use that in M-x shell.
>

Is the requirement for shell-file-name to be POSIX compatible documented
somewhere in the emacs documentation?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-16 11:09         ` David Bremner
@ 2017-08-16 20:16           ` Robert Ewald
  2017-08-17 11:44             ` David Bremner
  0 siblings, 1 reply; 11+ messages in thread
From: Robert Ewald @ 2017-08-16 20:16 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch


> On 16 Aug 2017, at 13:09, David Bremner <david@tethera.net> wrote:
> 
> Robert Ewald <robewald@gmx.net> writes:
> 
>>> On 16 Aug 2017, at 01:38, David Bremner <david@tethera.net> wrote:
> 
>> I did some research: apparently shell-file-name should be POSIX compatible,
>> otherwise many plugins don't work. explicit-shell-file-name however can be set to
>> fish or tcsh if you want to use that in M-x shell.
>> 
> 
> Is the requirement for shell-file-name to be POSIX compatible documented
> somewhere in the emacs documentation?

Not that I could find.

Robert

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-16 20:16           ` Robert Ewald
@ 2017-08-17 11:44             ` David Bremner
  2017-08-17 12:15               ` Tomi Ollila
  2017-08-17 21:46               ` David Bremner
  0 siblings, 2 replies; 11+ messages in thread
From: David Bremner @ 2017-08-17 11:44 UTC (permalink / raw)
  To: Robert Ewald; +Cc: notmuch

Robert Ewald <robewald@gmx.net> writes:

>> On 16 Aug 2017, at 13:09, David Bremner <david@tethera.net> wrote:
>> 
>> Robert Ewald <robewald@gmx.net> writes:
>> 
>>>> On 16 Aug 2017, at 01:38, David Bremner <david@tethera.net> wrote:
>> 
>>> I did some research: apparently shell-file-name should be POSIX compatible,
>>> otherwise many plugins don't work. explicit-shell-file-name however can be set to
>>> fish or tcsh if you want to use that in M-x shell.
>>> 
>> 
>> Is the requirement for shell-file-name to be POSIX compatible documented
>> somewhere in the emacs documentation?
>
> Not that I could find.
>
> Robert

OK, then I think we'd better be conservative in notmuch. Anecdotally I
think it is set to some *csh on BSD variants and (!) cmd.exe on windows
by default. We don't want people to have to change a default global
setting to use notmuch.  I believe there is work in progress to support
'make-process' which is new in emacs25, and would eliminate the need for
a shell wrapper there.

d

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-17 11:44             ` David Bremner
@ 2017-08-17 12:15               ` Tomi Ollila
  2017-08-17 21:46               ` David Bremner
  1 sibling, 0 replies; 11+ messages in thread
From: Tomi Ollila @ 2017-08-17 12:15 UTC (permalink / raw)
  To: David Bremner, Robert Ewald; +Cc: notmuch

On Thu, Aug 17 2017, David Bremner wrote:

> Robert Ewald <robewald@gmx.net> writes:
>
>>> On 16 Aug 2017, at 13:09, David Bremner <david@tethera.net> wrote:
>>> 
>>> Robert Ewald <robewald@gmx.net> writes:
>>> 
>>>>> On 16 Aug 2017, at 01:38, David Bremner <david@tethera.net> wrote:
>>> 
>>>> I did some research: apparently shell-file-name should be POSIX compatible,
>>>> otherwise many plugins don't work. explicit-shell-file-name however can be set to
>>>> fish or tcsh if you want to use that in M-x shell.
>>>> 
>>> 
>>> Is the requirement for shell-file-name to be POSIX compatible documented
>>> somewhere in the emacs documentation?
>>
>> Not that I could find.
>>
>> Robert
>
> OK, then I think we'd better be conservative in notmuch. Anecdotally I
> think it is set to some *csh on BSD variants and (!) cmd.exe on windows
> by default. We don't want people to have to change a default global
> setting to use notmuch.  I believe there is work in progress to support
> 'make-process' which is new in emacs25, and would eliminate the need for
> a shell wrapper there.

The effective line

/bin/sh -c ' exec 2>"$1"; shift; exec "$0" "$@" ' args...

Is neat trick (created by Austin, I[I]RC 2013-05) to have the command started
from emacs redirect stderr to a file while preserving argument list.
Before that we sometimes got errors intermixed to the output and sexp
parsing failed. I tried an alternative --stderr=FILE patch to notmuch,
which was applied, and then reverted by followup patch from me -- it
was useless as using that e.g. in remote notmuch use would have written
stderr on *remote* system and not locally. 

I tested what shell-file-name is defined by default on a freebsd KVM
instance -- it is /bin/csh -- and /bin/csh -c ' exec 2>"$1" '; does not work.

Many of have to host private patches to get their things work on their
"niche" ;) operating environments. Until (and if) emacs 25 make-process
approach is feasible, perhaps you have to host your own there.

Anyway, it is nice to see use of notmuch in many alternative systems, keep
up the good work!

Tomi

>
> d

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] emacs: Make the shell location configurable
  2017-08-17 11:44             ` David Bremner
  2017-08-17 12:15               ` Tomi Ollila
@ 2017-08-17 21:46               ` David Bremner
  1 sibling, 0 replies; 11+ messages in thread
From: David Bremner @ 2017-08-17 21:46 UTC (permalink / raw)
  To: Robert Ewald; +Cc: notmuch

David Bremner <david@tethera.net> writes:

>
> OK, then I think we'd better be conservative in notmuch. Anecdotally I
> think it is set to some *csh on BSD variants and (!) cmd.exe on windows
> by default. We don't want people to have to change a default global
> setting to use notmuch.  I believe there is work in progress to support
> 'make-process' which is new in emacs25, and would eliminate the need for
> a shell wrapper there.
>

In case you're not following the list closely, those patches are at

https://notmuchmail.org/pipermail/notmuch/2017/025018.html

feedback welcome.

d

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-08-17 21:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-14 22:36 [PATCH] emacs: Make the shell location configurable Robert Ewald
2017-08-15 13:53 ` Tomi Ollila
2017-08-15 16:02 ` David Bremner
2017-08-15 20:04   ` Robert Ewald
2017-08-15 23:38     ` David Bremner
2017-08-16  7:17       ` Robert Ewald
2017-08-16 11:09         ` David Bremner
2017-08-16 20:16           ` Robert Ewald
2017-08-17 11:44             ` David Bremner
2017-08-17 12:15               ` Tomi Ollila
2017-08-17 21:46               ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.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).