Skip to content

Commit

Permalink
lints
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed Sep 12, 2024
1 parent f071d8f commit 2d52bf0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
7 changes: 1 addition & 6 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,7 @@ mod tests {
fn ksh_ksh(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
let opts = Opts { cmd, hook, echo, resolve_symlinks };
let source = Ksh(&opts).render().unwrap();
Command::new("ksh")
.args(["-e", "-u", "-o", "norc", "-o", "pipefail", "-c", &source])
.assert()
.success()
.stdout("")
.stderr("");
Command::new("ksh").args(["-n", "-c", &source]).assert().success().stdout("").stderr("");
}

#[apply(opts)]
Expand Down
16 changes: 9 additions & 7 deletions templates/ksh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,26 @@ __zoxide_hook() {
}

# Initialize hook.
if [ "${PS1:=}" = "${PS1#*\$(__zoxide_hook)}" ]; then
if [[ "${PS1:=}" = "${PS1#*\$(__zoxide_hook)}" ]]; then
PS1="${PS1}\$(__zoxide_hook)"
fi

{%- when InitHook::Pwd -%}
# Hook to add new entries to the database.
__zoxide_hook() {
__zoxide_retval="$?"
__zoxide_newpwd="$(__zoxide_pwd)"
if [[ "${__zoxide_oldpwd:-__zoxide_newpwd}" != "${__zoxide_newpwd}" ]]; then
\command zoxide add -- "${__zoxide_newpwd}"
__zoxide_oldpwd="${__zoxide_newpwd}"
fi
return "${__zoxide_retval}"
}

# Initialize hook.
__zoxide_trap="$(\command trap -p DEBUG)"
if [[ ${__zoxide_trap} != *'__zoxide_hook'* ]]; then
\command trap "__zoxide_hook;${__zoxide_trap#;}" DEBUG
if [[ "${__zoxide_trap}" != *'__zoxide_hook'* ]]; then
\command trap "__zoxide_hook;${__zoxide_trap#';'}" DEBUG
fi
{%- endmatch %}

Expand All @@ -67,13 +69,13 @@ fi
# Jump to a directory using only keywords.
__zoxide_z() {
# shellcheck disable=SC2199
if [[ $# -eq 0 ]]; then
if (($# == 0)); then
__zoxide_cd ~
elif [[ $# -eq 1 && $1 == '-' ]]; then
elif [[ (($# == 1)) && $1 == '-' ]]; then
__zoxide_cd "${OLDPWD}"
elif [[ $# -eq 1 && -d $1 ]]; then
elif [[ (($# == 1)) && -d $1 ]]; then
__zoxide_cd "$1"
elif [[ $# -eq 2 && $1 == '--' ]]; then
elif [[ (($# == 2)) && $1 == '--' ]]; then
__zoxide_cd "$2"
else
# shellcheck disable=SC2312
Expand Down

0 comments on commit 2d52bf0

Please sign in to comment.