Posix compatibility fallback
andrewchambers opened this issue · comments
Using janetsh as my main shell has caused a few issues:
-
My login screen no longer shows my username as an option.
-
Pushing with git:
fatal: protocol error: bad line length character: unkn
Caused by an unimplemented flag.
I am pretty sure both are because janetsh does not implement posix semantics. I wonder if we can make a simple wrapper that detects cases when janetsh is used in these contexts and fall back to /bin/sh.
Cases we should consider:
- Unsupported flags.
- Running a script with a shebang that is obviously not janetsh
Added a command "janetsh-posix-wrapper" which can hopefully be set as a user shell and should not break anything by falling back to /bin/sh in anything but interactive use.
I wonder if the login screen issue is related to /etc/shells
. Have you added janetsh
there?
No, I will give that a try, thanks :)
@michaelforney Yup, that was the final bit.
Spoke too soon:
'/home/ac/repos/acnet': git-receive-pack: command not found
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Not sure if this is a nixos specific thing, it seems the shell profile (and hence paths) in my wrapper is not being loaded.
[ac@black:~/src/acnet] $ ssh "35.201.16.92" env
SSH_CONNECTION=121.74.82.199 44040 10.152.0.2 22
LANG=en_US.UTF-8
XDG_SESSION_ID=16
USER=ac
TZDIR=/etc/zoneinfo
NIX_PATH=nixpkgs=/nix/store/gmxd106zh8fpkzyz1k360ym0vwq11m3y-nixpkgs:nixpkgs-unstable=/nix/store/wfwsx89mhwh164v8dw2fj6bimix5wdbw-nixpkgs
PWD=/home/ac
HOME=/home/ac
SSH_CLIENT=121.74.82.199 44040 22
MAIL=/var/mail/ac
SHELL=/nix/store/9j33xyp3hv4ibnzmjjk940q9sc4yzb33-janetsh-0.0.1/bin/janetsh-posix-wrapper
SHLVL=1
LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
LOGNAME=ac
XDG_RUNTIME_DIR=/run/user/1000
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/nix/store/298rr0ik1kc15jj7y2fycdak7wvljm3x-openssh-7.9p1/bin
_=/usr/bin/env
0
Ah, I see the bug - $@ is unquoting single args into multiple args, breaking sh -c.
wrapper -c "ls -la"
-> exec sh -c ls -la
Fixed the problem, argv0 was important.