Skip to content

Commit

Permalink
Use POSIX implementation for ksh shells
Browse files Browse the repository at this point in the history
Only ksh93 supports DEBUG traps, and the rest don't have any features
that can be used for setting up hooks. May as well use the POSIX
implementation for all ksh shells.
  • Loading branch information
ajeetdsouza committed Jan 8, 2025
1 parent d99d82f commit 678bbde
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 183 deletions.
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,6 @@ zoxide can be installed in 4 easy steps:
</details>
<details>
<summary>Ksh</summary>
> Add this to the <ins>**end**</ins> of your config file (usually `~/.kshrc`):
>
> ```sh
> # ksh93
> eval "$(zoxide init ksh)"
>
> # mksh, oksh, etc.
> eval "$(zoxide init ksh --hook=prompt)"
> ```
</details>
<details>
<summary>Nushell</summary>
Expand Down
2 changes: 1 addition & 1 deletion contrib/completions/_zoxide

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contrib/completions/zoxide.bash

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion contrib/completions/zoxide.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions man/man1/zoxide-init.1
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ Add this to the \fBend\fR of your config file (usually
\fBzoxide init fish | source\fR
.fi
.TP
.B ksh
Add this to the \fBend\fR of your config file (usually \fB~/.kshrc\fR):
.sp
.nf
\fBeval $(zoxide init ksh)\fR
.fi
.TP
.B nushell
Add this to the \fBend\fR of your env file (find it by running
\fB$nu.env-path\fR in Nushell):
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ pub enum InitShell {
Bash,
Elvish,
Fish,
Ksh,
Nushell,
#[clap(alias = "ksh")]
Posix,
Powershell,
Xonsh,
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rinja::Template;
use crate::cmd::{Init, InitShell, Run};
use crate::config;
use crate::error::BrokenPipeHandler;
use crate::shell::{Bash, Elvish, Fish, Ksh, Nushell, Opts, Posix, Powershell, Xonsh, Zsh};
use crate::shell::{Bash, Elvish, Fish, Nushell, Opts, Posix, Powershell, Xonsh, Zsh};

impl Run for Init {
fn run(&self) -> Result<()> {
Expand All @@ -19,7 +19,6 @@ impl Run for Init {
InitShell::Bash => Bash(opts).render(),
InitShell::Elvish => Elvish(opts).render(),
InitShell::Fish => Fish(opts).render(),
InitShell::Ksh => Ksh(opts).render(),
InitShell::Nushell => Nushell(opts).render(),
InitShell::Posix => Posix(opts).render(),
InitShell::Powershell => Powershell(opts).render(),
Expand Down
37 changes: 0 additions & 37 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ macro_rules! make_template {
make_template!(Bash, "bash.txt");
make_template!(Elvish, "elvish.txt");
make_template!(Fish, "fish.txt");
make_template!(Ksh, "ksh.txt");
make_template!(Nushell, "nushell.txt");
make_template!(Posix, "posix.txt");
make_template!(Powershell, "powershell.txt");
Expand Down Expand Up @@ -159,42 +158,6 @@ mod tests {
.stderr("");
}

#[apply(opts)]
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(["-n", "-c", &source]).assert().success().stdout("").stderr("");
}

#[apply(opts)]
fn ksh_shellcheck(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("shellcheck")
.args(["--enable=all", "-"])
.write_stdin(source)
.assert()
.success()
.stdout("")
.stderr("");
}

#[apply(opts)]
fn ksh_shfmt(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
let opts = Opts { cmd, hook, echo, resolve_symlinks };
let mut source = Ksh(&opts).render().unwrap();
source.push('\n');

Command::new("shfmt")
.args(["--diff", "--indent=4", "--language-dialect=mksh", "--simplify", "-"])
.write_stdin(source)
.assert()
.success()
.stdout("")
.stderr("");
}

#[apply(opts)]
fn nushell_nushell(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
let opts = Opts { cmd, hook, echo, resolve_symlinks };
Expand Down
118 changes: 0 additions & 118 deletions templates/ksh.txt

This file was deleted.

0 comments on commit 678bbde

Please sign in to comment.