diff --git a/src/shell.rs b/src/shell.rs index 8812b1c..83d78e0 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -33,6 +33,26 @@ make_template!(Tcsh, "tcsh.txt"); make_template!(Xonsh, "xonsh.txt"); make_template!(Zsh, "zsh.txt"); +#[cfg(test)] +mod template_tests { + #[test] + fn windows_bash_and_zsh_pwd_substitute_before_cygpath() { + for (name, template) in [ + ("bash", include_str!("../templates/bash.txt")), + ("zsh", include_str!("../templates/zsh.txt")), + ] { + assert!( + template.contains(r#"\command cygpath -w "$({{ pwd }})""#), + "{name} template should pass the output of pwd to cygpath" + ); + assert!( + !template.contains(r#"\command cygpath -w "{{ pwd }}""#), + "{name} template should not pass the literal pwd command to cygpath" + ); + } + } +} + #[cfg(feature = "nix-dev")] #[cfg(test)] mod tests { diff --git a/templates/bash.txt b/templates/bash.txt index e5df5c7..d3be26c 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -16,7 +16,7 @@ function __zoxide_pwd() { {%- let pwd = "\\builtin pwd -L" -%} {%- endif -%} {%- if cfg!(windows) %} - \command cygpath -w "{{ pwd }}" + \command cygpath -w "$({{ pwd }})" {%- else %} {{ pwd }} {%- endif %} diff --git a/templates/zsh.txt b/templates/zsh.txt index c72178f..fe67c1f 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -16,7 +16,7 @@ function __zoxide_pwd() { {%- let pwd = "\\builtin pwd -L" -%} {%- endif -%} {%- if cfg!(windows) %} - \command cygpath -w "{{ pwd }}" + \command cygpath -w "$({{ pwd }})" {%- else %} {{ pwd }} {%- endif %}