mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2025-01-23 23:28:32 +00:00
Use /dev/null on Unix shells (#152)
This commit is contained in:
parent
7b00d5a423
commit
22d19a74b2
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Removed unnecessary backtraces on Rust nightly.
|
- Removed unnecessary backtraces on Rust nightly.
|
||||||
- Fixed generated shell code to avoid accidentally using aliased builtins.
|
- Fixed generated shell code to avoid accidentally using aliased builtins.
|
||||||
- Handle broken pipe errors gracefully when writing to streams.
|
- Handle broken pipe errors gracefully when writing to streams.
|
||||||
|
- NUL file appearing in working directory on Windows.
|
||||||
|
|
||||||
## [0.5.0] - 2020-10-30
|
## [0.5.0] - 2020-10-30
|
||||||
|
|
||||||
|
11
src/shell.rs
11
src/shell.rs
@ -8,13 +8,6 @@ pub struct Opts<'a> {
|
|||||||
pub resolve_symlinks: bool,
|
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 {
|
macro_rules! make_template {
|
||||||
($name:ident, $path:expr) => {
|
($name:ident, $path:expr) => {
|
||||||
#[derive(::std::fmt::Debug, ::askama::Template)]
|
#[derive(::std::fmt::Debug, ::askama::Template)]
|
||||||
@ -73,10 +66,10 @@ mod tests {
|
|||||||
for &hook in HOOKS {
|
for &hook in HOOKS {
|
||||||
for &cmd in CMDS {
|
for &cmd in CMDS {
|
||||||
let opt = Opts {
|
let opt = Opts {
|
||||||
|
cmd,
|
||||||
|
hook,
|
||||||
echo,
|
echo,
|
||||||
resolve_symlinks,
|
resolve_symlinks,
|
||||||
hook,
|
|
||||||
cmd,
|
|
||||||
};
|
};
|
||||||
opts.push(opt);
|
opts.push(opt);
|
||||||
}
|
}
|
||||||
|
@ -124,9 +124,9 @@ function __zoxide_zri() {
|
|||||||
# Remove definitions.
|
# Remove definitions.
|
||||||
function __zoxide_unset() {
|
function __zoxide_unset() {
|
||||||
# shellcheck disable=SC1001
|
# shellcheck disable=SC1001
|
||||||
\builtin unset -f "$@" &>{{ Opts::DEVNULL }}
|
\builtin unset -f "$@" &>/dev/null
|
||||||
# shellcheck disable=SC1001
|
# shellcheck disable=SC1001
|
||||||
\builtin unset -v "$@" &>{{ Opts::DEVNULL }}
|
\builtin unset -v "$@" &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
__zoxide_unset '{{cmd}}'
|
__zoxide_unset '{{cmd}}'
|
||||||
|
@ -104,9 +104,9 @@ end
|
|||||||
|
|
||||||
# Remove definitions.
|
# Remove definitions.
|
||||||
function __zoxide_unset
|
function __zoxide_unset
|
||||||
set --erase $argv > {{ Opts::DEVNULL }} 2>&1
|
set --erase $argv > /dev/null 2>&1
|
||||||
abbr --erase $argv > {{ Opts::DEVNULL }} 2>&1
|
abbr --erase $argv > /dev/null 2>&1
|
||||||
builtin functions --erase $argv > {{ Opts::DEVNULL }} 2>&1
|
builtin functions --erase $argv > /dev/null 2>&1
|
||||||
end
|
end
|
||||||
|
|
||||||
__zoxide_unset '{{cmd}}'
|
__zoxide_unset '{{cmd}}'
|
||||||
|
@ -126,9 +126,9 @@ __zoxide_zri() {
|
|||||||
# Remove definitions.
|
# Remove definitions.
|
||||||
__zoxide_unset() {
|
__zoxide_unset() {
|
||||||
# shellcheck disable=SC1001
|
# shellcheck disable=SC1001
|
||||||
\unset -f "$@" >{{ Opts::DEVNULL }} 2>&1
|
\unset -f "$@" >/dev/null 2>&1
|
||||||
# shellcheck disable=SC1001
|
# shellcheck disable=SC1001
|
||||||
\unset -v "$@" >{{ Opts::DEVNULL }} 2>&1
|
\unset -v "$@" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
__zoxide_unset '{{cmd}}'
|
__zoxide_unset '{{cmd}}'
|
||||||
|
@ -16,7 +16,7 @@ from builtins import events # type: ignore # pylint: disable=no-name-in-module
|
|||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
from typing import AnyStr, List, Optional
|
from typing import AnyStr, List, Optional
|
||||||
|
|
||||||
import xonsh.dirstack # type: ignore
|
import xonsh.dirstack # type: ignore # pylint: disable=import-error
|
||||||
|
|
||||||
{{ SECTION }}
|
{{ SECTION }}
|
||||||
# Utility functions for zoxide.
|
# Utility functions for zoxide.
|
||||||
|
@ -107,9 +107,9 @@ function __zoxide_zri() {
|
|||||||
|
|
||||||
# Remove definitions.
|
# Remove definitions.
|
||||||
function __zoxide_unset() {
|
function __zoxide_unset() {
|
||||||
\builtin unalias "$@" &>{{ Opts::DEVNULL }}
|
\builtin unalias "$@" &>/dev/null
|
||||||
\builtin unfunction "$@" &>{{ Opts::DEVNULL }}
|
\builtin unfunction "$@" &>/dev/null
|
||||||
\builtin unset "$@" &>{{ Opts::DEVNULL }}
|
\builtin unset "$@" &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
__zoxide_unset '{{cmd}}'
|
__zoxide_unset '{{cmd}}'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user