[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: set -m && bash -c "/bin/foo" works but bash -m -c "/bin/foo" doesn't
From: |
Chet Ramey |
Subject: |
Re: set -m && bash -c "/bin/foo" works but bash -m -c "/bin/foo" doesn't |
Date: |
Mon, 10 Oct 2022 15:48:26 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 |
On 10/9/22 3:50 PM, Britton Kerin wrote:
The man page says the options available to set are also usable from
the command line.
I wanted to run a backgroup script in a new process group from vim and
print the PGID.
I ended up with the following:
:echo system('set -m && bash -c '."'".'((/bin/foo &) && eval
"echo -n \$\$")'."'")
I thought it would be nicer to use bash -m but it doesn't work (simple example):
:echo system('bash -m -c "echo foo"')
It works for me from a terminal:
$ ../bash-5.2-patched/bash -m -c '/bin/echo foo'
foo
and in a pipeline:
$ echo abcde | ../bash-5.2-patched/bash -m -c '/bin/cat' | /bin/cat
abcde
says:
bash: cannot set terminal process group (31921): Inappropriate
ioctl for device
bash: no job control in this shell
So it seems bash -m and set -m are not equivalent in this context at least.
You get that message when bash doesn't have a controlling terminal or isn't
in the terminal's foreground process group, when job control isn't
possible.
You might try
bash -c 'set -m ; rest of command string'
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/