diff --git a/CHANGELOG.md b/CHANGELOG.md index 632b5a8..5493d94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed unnecessary backtraces on Rust nightly. - Fixed generated shell code to avoid accidentally using aliased builtins. - Handle broken pipe errors gracefully when writing to streams. +- NUL file appearing in working directory on Windows. ## [0.5.0] - 2020-10-30 diff --git a/src/shell.rs b/src/shell.rs index 120a4e5..0636187 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -8,13 +8,6 @@ pub struct Opts<'a> { pub resolve_symlinks: bool, } -impl Opts<'_> { - #[cfg(unix)] - pub const DEVNULL: &'static str = "/dev/null"; - #[cfg(windows)] - pub const DEVNULL: &'static str = "NUL"; -} - macro_rules! make_template { ($name:ident, $path:expr) => { #[derive(::std::fmt::Debug, ::askama::Template)] @@ -73,10 +66,10 @@ mod tests { for &hook in HOOKS { for &cmd in CMDS { let opt = Opts { + cmd, + hook, echo, resolve_symlinks, - hook, - cmd, }; opts.push(opt); } diff --git a/templates/bash.txt b/templates/bash.txt index 7f042b5..1bf1cf0 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -124,9 +124,9 @@ function __zoxide_zri() { # Remove definitions. function __zoxide_unset() { # shellcheck disable=SC1001 - \builtin unset -f "$@" &>{{ Opts::DEVNULL }} + \builtin unset -f "$@" &>/dev/null # shellcheck disable=SC1001 - \builtin unset -v "$@" &>{{ Opts::DEVNULL }} + \builtin unset -v "$@" &>/dev/null } __zoxide_unset '{{cmd}}' diff --git a/templates/fish.txt b/templates/fish.txt index 2d04d8f..fb854d0 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -104,9 +104,9 @@ end # Remove definitions. function __zoxide_unset - set --erase $argv > {{ Opts::DEVNULL }} 2>&1 - abbr --erase $argv > {{ Opts::DEVNULL }} 2>&1 - builtin functions --erase $argv > {{ Opts::DEVNULL }} 2>&1 + set --erase $argv > /dev/null 2>&1 + abbr --erase $argv > /dev/null 2>&1 + builtin functions --erase $argv > /dev/null 2>&1 end __zoxide_unset '{{cmd}}' diff --git a/templates/posix.txt b/templates/posix.txt index 9789818..41bdd26 100644 --- a/templates/posix.txt +++ b/templates/posix.txt @@ -126,9 +126,9 @@ __zoxide_zri() { # Remove definitions. __zoxide_unset() { # shellcheck disable=SC1001 - \unset -f "$@" >{{ Opts::DEVNULL }} 2>&1 + \unset -f "$@" >/dev/null 2>&1 # shellcheck disable=SC1001 - \unset -v "$@" >{{ Opts::DEVNULL }} 2>&1 + \unset -v "$@" >/dev/null 2>&1 } __zoxide_unset '{{cmd}}' diff --git a/templates/xonsh.txt b/templates/xonsh.txt index c8c9a36..1e59cf4 100644 --- a/templates/xonsh.txt +++ b/templates/xonsh.txt @@ -16,7 +16,7 @@ from builtins import events # type: ignore # pylint: disable=no-name-in-module from subprocess import CalledProcessError from typing import AnyStr, List, Optional -import xonsh.dirstack # type: ignore +import xonsh.dirstack # type: ignore # pylint: disable=import-error {{ SECTION }} # Utility functions for zoxide. diff --git a/templates/zsh.txt b/templates/zsh.txt index 7d9fbe6..9d6a6a8 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -107,9 +107,9 @@ function __zoxide_zri() { # Remove definitions. function __zoxide_unset() { - \builtin unalias "$@" &>{{ Opts::DEVNULL }} - \builtin unfunction "$@" &>{{ Opts::DEVNULL }} - \builtin unset "$@" &>{{ Opts::DEVNULL }} + \builtin unalias "$@" &>/dev/null + \builtin unfunction "$@" &>/dev/null + \builtin unset "$@" &>/dev/null } __zoxide_unset '{{cmd}}'