[PATCH] emacs: Make the shell location configurable

classic Classic list List threaded Threaded
11 messages Options
Robert Ewald Robert Ewald
Reply | Threaded
Open this post in threaded view
|

[PATCH] emacs: Make the shell location configurable

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

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable

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
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable

In reply to this post by Robert Ewald
Robert Ewald <[hidden email]> 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
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Robert Ewald Robert Ewald
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable

Hello,

Thanks for reviewing the patch.

> On 15 Aug 2017, at 18:02, David Bremner <[hidden email]> wrote:
>
> Robert Ewald <[hidden email]> 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

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable

Robert Ewald <[hidden email]> 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
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Robert Ewald Robert Ewald
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable


> On 16 Aug 2017, at 01:38, David Bremner <[hidden email]> wrote:
>
> Robert Ewald <[hidden email]> 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.
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable

Robert Ewald <[hidden email]> writes:

>> On 16 Aug 2017, at 01:38, David Bremner <[hidden email]> 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?
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Robert Ewald Robert Ewald
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable


> On 16 Aug 2017, at 13:09, David Bremner <[hidden email]> wrote:
>
> Robert Ewald <[hidden email]> writes:
>
>>> On 16 Aug 2017, at 01:38, David Bremner <[hidden email]> 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
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable

Robert Ewald <[hidden email]> writes:

>> On 16 Aug 2017, at 13:09, David Bremner <[hidden email]> wrote:
>>
>> Robert Ewald <[hidden email]> writes:
>>
>>>> On 16 Aug 2017, at 01:38, David Bremner <[hidden email]> 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
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable

On Thu, Aug 17 2017, David Bremner wrote:

> Robert Ewald <[hidden email]> writes:
>
>>> On 16 Aug 2017, at 13:09, David Bremner <[hidden email]> wrote:
>>>
>>> Robert Ewald <[hidden email]> writes:
>>>
>>>>> On 16 Aug 2017, at 01:38, David Bremner <[hidden email]> 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
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: Make the shell location configurable

In reply to this post by David Bremner-2
David Bremner <[hidden email]> 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
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch