D.M. Procida <
real-not-anti...@apple-juice.co.uk> wrote:
> Richard Tobin <
ric...@cogsci.ed.ac.uk> wrote:
> You are absolutely right, and removing the -w makes it work again.
> However, it wasn't me that set it, it was set by TextMate:
>
> > To use TextMate as editor for subversion, git, and similar you need to
> > install the mate shell command and add a line like the following to
> > ~/.bashrc:
> >
> > export EDITOR="/usr/local/bin/mate -w"
>
> The -w flag makes it wait for the edit to finish - which isn't needed
> for this application, but is required for Git.
I saw this kind of thing with Python's subprocess recently.
'subprocess.run' calls execvpe() behind the scenes. The behaviour (on
Ubuntu) of some programs is different whether you have 'run in a shell'
enabled or not. I think the issue is that calling:
subprocess.run(["/usr/local/bin/mate -w"], shell=False)
expects the argument to the be name of the program, whereas:
subprocess.run(["/usr/local/bin/mate -w"], shell=True)
runs a shell and passes the string '/usr/local/bin/mate -w' to it. Being a
shell it sees the input as a shell script, does the argument separation, and
then looks for /usr/local/bin/mate with argv[1] set to '-w'.
In Python the way to run the original without a shell would have been:
subprocess.run(["/usr/local/bin/mate", "-w"])
which makes the argument separation explicit.
In my case, the problem was more like:
subprocess.run(["/blah/blah/blah.sh"], shell=False)
and calling exec on something that happened to be a shell script (which
turned out to be a hidden frontend to a real binary and so didn't have a .sh
suffix to make it obvious) didn't work without first running it in a shell.
Theo