Use /dev/null on shells

This commit is contained in:
Ajeet D'Souza 2021-03-01 03:27:16 +05:30
parent 7b00d5a423
commit acf070f194
7 changed files with 12 additions and 18 deletions

View File

@ -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

View File

@ -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)]

View File

@ -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}}'

View File

@ -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}}'

View File

@ -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}}'

View File

@ -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.

View File

@ -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}}'