vmactions / netbsd-vm

Use NetBSD in github actions
MIT License
21 stars 1 forks source link

The default root shell is not /bin/ksh but /bin/sh on NetBSD #10

Closed tsutsui closed 2 months ago

tsutsui commented 2 months ago

README.md says:

The default shell in NetBSD is ksh, if you want to use sh to execute the run script, please set usesh to true.

However the default root shell has been /bin/sh since NetBSD 6.0: https://github.com/NetBSD/src/commit/a1da65bdfb8783a1da69f02917eb858477115152

Change root's default shell to /bin/sh, to provide a default which has command line editing, tab completion, and other features users have come to expect from a modern OS.

Discussed on current-users approximately two weeks ago. Should be pulled up for NetBSD 6.0.

On the other hand, OpenBSD actually uses /bin/ksh for root: https://github.com/openbsd/src/commit/850c97e0fd6ce968556a6698cd0c0d6a78172c35

change root login shell to ksh as promised; ok many

Note it looks FreeBSD has changed the default root shell to /bin/sh since FreeBSD 14: https://github.com/freebsd/freebsd-src/commit/d410b585b6f00a26c2de7724d6576a3ea7d548b7

sh(1): make it the default shell for the root user

In the recent history sh(1) has gain the missing features for it to become a usable interractive shell:

  • command completion
  • persistent history support
  • improvements on the default bindings in emacs mode
  • improvements in the vi mode (repect $EDITOR)
  • print a newline when exiting via ^D
  • default prompt and improvements on how PS1 can be configured
  • and more.

This changes also simplifies making tiny freebsd images with only sh(1) as a shell

Anyway, it looks run.sh should invoke ssh with -t to make sure ~/.profile is loaded, otherwise we have to explicitly set PATH environment for commands in /usr/pkg/sbin etc.

diff --git a/run.sh b/run.sh
index 589806d..21695c1 100644
--- a/run.sh
+++ b/run.sh
@@ -129,7 +129,7 @@ execSSH() {

 #using the sh 
 execSSHSH() {
-  exec ssh "$osname" sh
+  exec ssh -t "$osname" sh
 }