feat: support rbash (strict mode)

resolves #2109
This commit is contained in:
Jan De Dobbeleer 2022-04-20 07:02:12 +02:00 committed by Jan De Dobbeleer
parent b3b5267605
commit bb9b6197d5
3 changed files with 8 additions and 1 deletions

View file

@ -14,6 +14,7 @@ import (
var (
print bool
strict bool
initCmd = &cobra.Command{
Use: "init [bash|zsh|fish|powershell|pwsh|cmd|nu] --config ~/.mytheme.omp.json",
@ -42,6 +43,7 @@ See the documentation to initialize your shell: https://ohmyposh.dev/docs/prompt
func init() { // nolint:gochecknoinits
initCmd.Flags().BoolVarP(&print, "print", "p", false, "print the init script")
initCmd.Flags().BoolVarP(&strict, "strict", "s", false, "run in strict mode")
_ = initCmd.MarkPersistentFlagRequired("config")
rootCmd.AddCommand(initCmd)
}
@ -52,6 +54,7 @@ func runInit(shellName string) {
CmdFlags: &environment.Flags{
Shell: shellName,
Config: config,
Strict: strict,
},
}
env.Init(false)

View file

@ -42,6 +42,7 @@ type Flags struct {
StackCount int
Migrate bool
TerminalWidth int
Strict bool
}
type CommandError struct {

View file

@ -38,6 +38,9 @@ func getExecutablePath(env environment.Environment) (string, error) {
if err != nil {
return "", err
}
if env.Flags().Strict {
return environment.Base(env, executable), nil
}
// On Windows, it fails when the excutable is called in MSYS2 for example
// which uses unix style paths to resolve the executable's location.
// PowerShell knows how to resolve both, so we can swap this without any issue.