mirror of
https://github.com/troglobit/finit.git
synced 2026-11-10 16:31:21 +00:00
initctl: restore Andreas' clever $(command ...) eval, it works
Turns out that on some systems, that has none of the first two, and
neither of the two environment variables set in ${VISUAL:-${EDITOR}},
they evaluate to 'sh /etc/finit.d/file.conf', which is true, so we
wouldn't even try mg or vi ...
This patch reverts to the spirit of Andreas Egebergs initial commit,
which turns out to be a better solution anyway :)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
49582c70c5
commit
2ac39e1917
1 file changed
+17
-4
+17
-4
@@ -244,14 +244,27 @@ int serv_touch(char *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to open an editor for the given file, if creat is given we
|
||||||
|
* create a new file based on /lib/finit/sample.conf
|
||||||
|
*
|
||||||
|
* The order of editors that this command checks for is evaluated
|
||||||
|
* as follows, in order:
|
||||||
|
*
|
||||||
|
* sensible-editor :: debian based systems
|
||||||
|
* editor :: debian + most other systems
|
||||||
|
* VISUAL :: full-screen editor program
|
||||||
|
* EDITOR :: line-mode editor program
|
||||||
|
* $(command ...) :: fallback to mg or vi
|
||||||
|
*
|
||||||
|
* For details: https://jdebp.uk/FGA/unix-editors-and-pagers.html
|
||||||
|
*/
|
||||||
static int do_edit(char *arg, int creat)
|
static int do_edit(char *arg, int creat)
|
||||||
{
|
{
|
||||||
char *editor[] = {
|
char *editor[] = {
|
||||||
"sensible-editor",
|
"sensible-editor",
|
||||||
"editor",
|
"editor",
|
||||||
"${VISUAL:-${EDITOR}}",
|
"${VISUAL:-${EDITOR:$(command -v mg vi | head -1)}}"
|
||||||
"mg",
|
|
||||||
"vi"
|
|
||||||
};
|
};
|
||||||
char path[256];
|
char path[256];
|
||||||
char *fn;
|
char *fn;
|
||||||
@@ -259,7 +272,7 @@ static int do_edit(char *arg, int creat)
|
|||||||
fn = conf(path, sizeof(path), arg, creat);
|
fn = conf(path, sizeof(path), arg, creat);
|
||||||
if (!fexist(fn)) {
|
if (!fexist(fn)) {
|
||||||
if (!creat) {
|
if (!creat) {
|
||||||
warnx("Cannot find %s, use create command, or select one of:", arg);
|
warnx("Cannot find %s, use -c flag, create command, or select one of:", arg);
|
||||||
return serv_list("available");
|
return serv_list("available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user