oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.86k stars 159 forks source link

Issues after running/exiting shells from OSH #500

Open Wychmire opened 5 years ago

Wychmire commented 5 years ago

This happens at Master and the 0.7.pre4 tarball. Ion In most cases you'll need to compile Ion yourself, almost all distro packages are horribly out-of-date: https://gitlab.redox-os.org/redox-os/ion If you run Ion from a terminal using OSH as the login shell and then exit Ion, OSH will exit as well. ^D is briefly visible before the terminal closes.

bash$ osh
osh$ ion
ion$ exit
[1]+  Stopped                 osh
bash$

fish Running fish from an instance of OSH is weirder; typed output doesn't show up (though commands and std{out,err} still work), including newlines.

bash$ osh
osh$ fish
fish$ exit
osh$ [enter] osh$ {echo "foo"} foo
osh$ {exit}
bash$

(square brackets are key presses, things in squiggly brackets are commands that can't be seen)

andychu commented 5 years ago

Oh weird... :-( I just tried fish on my Ubuntu machine and it seems to work.

However I bet this has something to do with the login shell? Which I haven't tested. I'm actually not completely sure what is different about a login shell, and maybe that's part of the problem :-/

$ osh --version
Oil version 0.7.pre4
Release Date: 2019-09-02 18:48:24+00:00
Arch: x86_64
OS: Linux
Platform: #46~16.04.1-Ubuntu SMP Thu May 3 10:06:43 UTC 2018
Compiler: GCC 5.4.0 20160609
Interpreter: OVM
Interpreter version: 2.7.13
Bytecode: bytecode-opy.zip
andy@lisa:~/git/oilshell/oil$ osh
  shopt -s globstar  # long overdue, try out wc -l **/*.py
  ^~~~~
/home/andy/git/dotfiles//interactive.bash:23: 'shopt' got invalid option 'globstar'
[osh] lisa ~/git/oilshell/oil$ fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
andy@lisa ~/g/o/oil> ls
asdl/        _build/     _devbuild/   fastlex.so@  libc.pyi        logs-0.6.pre13.tar  native/             osh/               __pycache__/        release-roadmap.txt@  tags                  TODO.txt@      uftrace.data.old/
asdl.txt@    _chroot/    devtools/    frontend/    libc.so@        l.txt               NOTES-cpython.txt@  ovm2/              pylib/              rfc/                  test/                 tools/         Vagrantfile
benchmarks/  configure*  dir/         gold/        LICENSE.txt     Makefile            NOTES.txt@          pgen2/             Python-2.7.13/      Rplots.pdf            testdata/             types/         vendor/
bin/         core/       doc/         __init__.py  line_input.so@  metrics/            oil_lang/           portable-rules.mk  README.md           script*               _tmp/                 types.txt      web/
_bin/        demo/       dyn.py       install*     lint.txt        misc/               oil-version.txt     posix_.pyi         _release/           spec/                 TODO-blog.txt@        typ.txt
build/       _deps/      fastlex.pyi  INSTALL.txt  local.sh@       mycpp/              opy/                posix_.so@         release-notes.txt@  stdlib/               TODO-completion.txt@  uftrace.data/
andy@lisa ~/g/o/oil> exit

[osh] lisa ~/git/oilshell/oil$ 
andychu commented 5 years ago

Actually I tried with a different user that has osh as its shell, and couldn't repro the problem with fish.

What OS are you using? readline version, etc. ?

$ sudo su osh-user
osh$ osh --version
Oil version 0.7.pre4
Release Date: 2019-09-02 18:48:24+00:00
Arch: x86_64
OS: Linux
Platform: #46~16.04.1-Ubuntu SMP Thu May 3 10:06:43 UTC 2018
Compiler: GCC 5.4.0 20160609
Interpreter: OVM
Interpreter version: 2.7.13
Bytecode: bytecode-opy.zip
osh$ fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
osh-user@lisa /h/andy> cd /
osh-user@lisa /> ls
alpine/  bin/  boot/  cdrom/  dev/  etc/  home/  initrd.img@  initrd.img.old@  lib/  lib32/  lib64/  libx32/  lost+found/  media/  mnt/  nix/  opt/  proc/  root/  run/  sbin/  snap/  srv/  sys/  tmp/  usr/  var/  vmlinuz@  vmlinuz.old@
osh-user@lisa /> exit
andychu commented 5 years ago

The fish thing sounds like some terminal-related problem, i.e. ANSI control codes not being properly shown.

I'm not sure if the shell has to do anything special there. I opened a new tab with roxterm before doing sudo su osh-user.

Wychmire commented 5 years ago

Login shell is set to Fish right now, not OSH. It happens when set to OSH, Bash, or Ion though. I'v logged out/in to make sure the login shell is working properly. All I have to do is something like this:

fish$ osh  # fish is the default login shell
 osh$ ion  # to trigger the ion problem, run fish to trigger the fish problem
 ion$ exit
fish$      # Back to fish, instead of osh

Actual output from a terminal:

Welcome to fish, the friendly interactive shell
caleba@ironstone ~> osh
osh$ ion
[~]$ exit
Job 1, 'osh' has stopped
caleba@ironstone ~> 

Void Linux, readline v8.0.0 (this problem happened when I was using Arch as well.)

$ osh --version
Oil version 0.7.pre4
Release Date: 2019-09-02 19:11:10+00:00
Arch: x86_64
OS: Linux
Platform: #1 SMP PREEMPT Tue Oct 1 19:29:47 UTC 2019
Compiler: GCC 9.1.0
Interpreter: OVM
Interpreter version: 2.7.13
Bytecode: bytecode-opy.zip
andychu commented 5 years ago

Hm, not sure what's going on but one thing that's weird is that my timestamp looks like this:

Oil version 0.7.pre4
Release Date: 2019-09-02 18:48:24+00:00

and yours looks like this:

Oil version 0.7.pre4
Release Date: 2019-09-02 19:11:10+00:00

OK I guess that means you're running the dev build, rather than the tarball.

That is, you're depending on the system Python, rather than using the OSH binary.

That may or may not be the cause of the problem, but it's relevant ...

andychu commented 5 years ago

I'm trying to remember how the release date thing works, and am getting confused... I'm not sure why NEITHER of ours matches the file in the app bundle:

andy@lisa:~/src/oil/oil-0.7.pre4/_build/oil$ cat release-date.txt 
2019-09-01 03:15:09+00:00
Wychmire commented 5 years ago

I downloaded the 0.7.pre4 tarball, compiled it, and ran /usr/local/bin/osh --version. I still get Release Date: 2019-09-02 19:11:10+00:00. The issues with running other shells from inside OSH still occur with the new binary.

I know I get the issue on Void and Arch Linux, I'll go test on Kubuntu on report my findings

Edit: It's worth noting that I get the expected result (OSH functions normally) if I run bash and then exit.

Wychmire commented 5 years ago

Oilshell compiled on Kubuntu:

$ osh --version
Oil version 0.7.pre4
Release Date: 2019-09-02 19:11:10+00:00
Arch: x86_64
OS: Linux
Platform: #31-Ubuntu SMP Thu Sep 12 13:05:32 UTC 2019
Compiler: GCC 8.3.0
Interpreter: OVM
Interpreter version: 2.7.13
Bytecode: bytecode-opy.zip

The fish error still occurs, however if I then exit OSH the "no-newlines and invisible text" carries over to Bash (the default shell in my Kubuntu install). I wasn't able to test Ion as it wouldn't compile.

I also installed zsh and ran it from OSH, everything works as it should.

andychu commented 5 years ago

Another bug starting OSH from fish?

https://oilshell.zulipchat.com/#narrow/stream/121539-oil-dev/topic/Parsing.20bug.20reproducible.20example