diff --git a/complete.go b/complete.go index 29c351c9..8d7f13e6 100644 --- a/complete.go +++ b/complete.go @@ -138,6 +138,7 @@ var ( "promptfmt", "ratios", "shell", + "shellflag", "shellopts", "sortby", "timefmt", diff --git a/doc.go b/doc.go index 0f7c65bb..2a4501b8 100644 --- a/doc.go +++ b/doc.go @@ -126,6 +126,7 @@ The following options can be used to customize the behavior of lf: reverse bool (default off) scrolloff int (default 0) shell string (default 'sh' for unix and 'cmd' for windows) + shellflag string (default '-c' for unix and '/c' for windows) shellopts []string (default '') smartcase bool (default on) smartdia bool (default off) @@ -641,8 +642,11 @@ A smaller offset can be used when the current file is close to the beginning or shell string (default 'sh' for unix and 'cmd' for windows) Shell executable to use for shell commands. -Shell commands are executed as 'shell shellopts -c command -- arguments'. -On windows, '/c' is used instead of '-c' which should work in 'cmd' and 'powershell'. +Shell commands are executed as 'shell shellopts shellflag command -- arguments'. + + shellflag string (default '-c' for unix and '/c' for windows) + +Command line flag used to pass shell commands. shellopts []string (default '') diff --git a/docstring.go b/docstring.go index 7458e425..d90109de 100644 --- a/docstring.go +++ b/docstring.go @@ -129,6 +129,7 @@ The following options can be used to customize the behavior of lf: reverse bool (default off) scrolloff int (default 0) shell string (default 'sh' for unix and 'cmd' for windows) + shellflag string (default '-c' for unix and '/c' for windows) shellopts []string (default '') smartcase bool (default on) smartdia bool (default off) @@ -685,8 +686,11 @@ beginning or end of the list to show the maximum number of items. shell string (default 'sh' for unix and 'cmd' for windows) Shell executable to use for shell commands. Shell commands are executed as -'shell shellopts -c command -- arguments'. On windows, '/c' is used instead -of '-c' which should work in 'cmd' and 'powershell'. +'shell shellopts shellflag command -- arguments'. + + shellflag string (default '-c' for unix and '/c' for windows) + +Command line flag used to pass shell commands. shellopts []string (default '') diff --git a/eval.go b/eval.go index e83aa3bc..f7cc7197 100644 --- a/eval.go +++ b/eval.go @@ -309,6 +309,8 @@ func (e *setExpr) eval(app *app, args []string) { app.ui.loadFile(app.nav, true) case "shell": gOpts.shell = e.val + case "shellflag": + gOpts.shellflag = e.val case "shellopts": if e.val == "" { gOpts.shellopts = nil diff --git a/lf.1 b/lf.1 index 7032d4ff..8ad1926c 100644 --- a/lf.1 +++ b/lf.1 @@ -141,6 +141,7 @@ The following options can be used to customize the behavior of lf: reverse bool (default off) scrolloff int (default 0) shell string (default 'sh' for unix and 'cmd' for windows) + shellflag string (default '-c' for unix and '/c' for windows) shellopts []string (default '') smartcase bool (default on) smartdia bool (default off) @@ -764,7 +765,13 @@ Minimum number of offset lines shown at all times in the top and the bottom of t shell string (default 'sh' for unix and 'cmd' for windows) .EE .PP -Shell executable to use for shell commands. Shell commands are executed as 'shell shellopts -c command -- arguments'. On windows, '/c' is used instead of '-c' which should work in 'cmd' and 'powershell'. +Shell executable to use for shell commands. Shell commands are executed as 'shell shellopts shellflag command -- arguments'. +.PP +.EX + shellflag string (default '-c' for unix and '/c' for windows) +.EE +.PP +Command line flag used to pass shell commands. .PP .EX shellopts []string (default '') diff --git a/opts.go b/opts.go index 0250e453..95b61c10 100644 --- a/opts.go +++ b/opts.go @@ -55,6 +55,7 @@ var gOpts struct { cleaner string promptfmt string shell string + shellflag string timefmt string truncatechar string ratios []int @@ -95,6 +96,7 @@ func init() { gOpts.cleaner = "" gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m" gOpts.shell = gDefaultShell + gOpts.shellflag = gDefaultShellFlag gOpts.timefmt = time.ANSIC gOpts.truncatechar = "~" gOpts.ratios = []int{1, 2, 3} diff --git a/os.go b/os.go index e51c85d6..6775bcc9 100644 --- a/os.go +++ b/os.go @@ -23,6 +23,7 @@ var ( var ( gDefaultShell = "sh" + gDefaultShellFlag = "-c" gDefaultSocketProt = "unix" gDefaultSocketPath string ) @@ -99,7 +100,7 @@ func shellCommand(s string, args []string) *exec.Cmd { s = fmt.Sprintf("IFS='%s'; %s", gOpts.ifs, s) } - args = append([]string{"-c", s, "--"}, args...) + args = append([]string{gOpts.shellflag, s, "--"}, args...) args = append(gOpts.shellopts, args...) diff --git a/os_windows.go b/os_windows.go index 37fb296f..bc8ff5fb 100644 --- a/os_windows.go +++ b/os_windows.go @@ -22,6 +22,7 @@ var envPathExt = os.Getenv("PATHEXT") var ( gDefaultShell = "cmd" + gDefaultShellFlag = "/c" gDefaultSocketProt = "tcp" gDefaultSocketPath = "127.0.0.1:12345" ) @@ -77,7 +78,7 @@ func detachedCommand(name string, arg ...string) *exec.Cmd { } func shellCommand(s string, args []string) *exec.Cmd { - args = append([]string{"/c", s}, args...) + args = append([]string{gOpts.shellflag, s}, args...) args = append(gOpts.shellopts, args...)