Skip to content

Commit 7822773

Browse files
authored
Add /usr/bin/nu to /etc/shells after installation (#36)
Add /usr/bin/nu to /etc/shells after install, and Remove nu from /etc/shells before uninstall, fixes #34, fixes nushell/nushell#15275
1 parent aedf9ea commit 7822773

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
apk update || true
3636
# Use --allow-untrusted since the apk package is not signed currently
3737
apk add --allow-untrusted nushell
38+
cat /etc/shells
3839
nu -c '$nu.current-exe | print; version'
3940
4041
install-rpm:
@@ -66,6 +67,7 @@ jobs:
6667
gpgkey=https://yum.fury.io/nushell/gpg.key" | tee /etc/yum.repos.d/fury-nushell.repo
6768
# Install Nushell via dnf
6869
dnf install -y nushell
70+
cat /etc/shells
6971
# Print nushell version to verify installation
7072
nu -c '$nu.current-exe | print; ls $nu.default-config-dir | print; version'
7173
@@ -83,6 +85,7 @@ jobs:
8385
echo "deb https://apt.fury.io/nushell/ /" | sudo tee /etc/apt/sources.list.d/fury.list
8486
sudo apt update
8587
sudo apt install nushell
88+
cat /etc/shells
8689
nu -c '$nu.current-exe | print; ls $nu.default-config-dir | print; version'
8790
8891
install-on-arch:
@@ -98,6 +101,7 @@ jobs:
98101
| grep browser_download_url | cut -d '"' -f 4 | grep x86_64.pkg.tar.zst \
99102
| xargs wget -O nushell.pkg.tar.zst
100103
pacman -U --noconfirm nushell.pkg.tar.zst
104+
cat /etc/shells
101105
nu -c '$nu.current-exe | print; ls $nu.default-config-dir | print; version'
102106
103107
install-on-debian:
@@ -124,4 +128,5 @@ jobs:
124128
echo "deb [trusted=yes] https://apt.fury.io/nushell/ /" | tee /etc/apt/sources.list.d/fury.list
125129
apt update
126130
apt install nushell
131+
cat /etc/shells
127132
nu -c '$nu.current-exe | print; ls $nu.default-config-dir | print; version'

nfpm.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@ contents:
106106
dst: /usr/libexec/nushell/nu_plugin_formats
107107
- src: ./scripts/post-install.nu
108108
dst: /usr/libexec/nushell/post-install.nu
109+
- src: ./scripts/pre-remove.nu
110+
dst: /usr/libexec/nushell/pre-remove.nu
109111
- src: ./release/LICENSE
110112
dst: /usr/share/licenses/nushell/LICENSE
111113

112114
# Scripts to run at specific stages. (overridable)
113115
scripts:
116+
preremove: ./scripts/pre-remove.sh
114117
postinstall: ./scripts/post-install.sh
115118

116119
# Custom configuration applied only to the Deb packager.

scripts/post-install.nu

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ def 'setup-plugins' [] {
3030
# plugin list | select name version filename | print
3131
}
3232

33+
# Add /usr/bin/nu to /etc/shells if it's not already there
34+
def 'add-shells' [] {
35+
let shells = open /etc/shells
36+
if not ($shells =~ $'/usr/bin/nu') {
37+
echo $'/usr/bin/nu(char nl)' o>> /etc/shells
38+
}
39+
}
40+
3341
def main [] {
3442
setup-plugins
43+
add-shells
3544
}

scripts/pre-remove.nu

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env nu
2+
# Author: hustcer
3+
# Created: 2025/03/10 08:25:20
4+
# Description: Script to run before removing Nushell.
5+
6+
# Remove /usr/bin/nu from /etc/shells
7+
def 'remove-shells' [] {
8+
open /etc/shells
9+
| lines
10+
| where $it !~ '/usr/bin/nu'
11+
| str join "\n"
12+
| save -rf /etc/shells
13+
}
14+
15+
def main [] {
16+
remove-shells
17+
}

scripts/pre-remove.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
# Author: hustcer
3+
# Created: 2025/03/10 08:35:20
4+
5+
nu /usr/libexec/nushell/pre-remove.nu

0 commit comments

Comments
 (0)