vsh
vsh copied to clipboard
trying to execute a second command in vsh fails
Do you have any more details to replicate? It seems to work for me
Type any command and then type any command again. It will not record the second command or any command after it.
Example
v# echo hi hi v# echo hi
After this example is executed it will not run "echo hi" the second time, it just goes to the next line and does not show "v#" prompt. Any commands given to the broken prompt doesn't run.
It might also be that I am on macOS.
I'm on Mac, too, but I also haven't updated V for some time.. maybe something broke there. I'll check and let you know.
Ok 👍
Tell me when you find the problem.
Confirmed this works for me with: V 0.2.2 8547762
. My HEAD is at 8547762ab
.
Welcome to v shell!
v# echo hi
hi
v# echo it works
it works
v# echo something else
something else
v# jacobsalmela:~/vsh (main)$
Time for some bisect
ing...
jacobsalmela:~/vlang ((no branch, bisect started on master))$ git bisect good
453fb1b08b7bcce8ef86c175aa3b1179f4a01c2e is the first bad commit
commit 453fb1b08b7bcce8ef86c175aa3b1179f4a01c2e
Author: Delyan Angelov <[email protected]>
Date: Tue May 18 11:59:57 2021 +0300
term.ui: use os.signal_opt instead of os.signal
vlib/os/signal.c.v | 66 ++++++++++++++++++++-----------------
vlib/term/ui/consoleapi_windows.c.v | 2 --
vlib/term/ui/input.v | 6 ++--
vlib/term/ui/input_windows.c.v | 4 +--
vlib/term/ui/termios_nix.c.v | 18 ++++++----
5 files changed, 53 insertions(+), 43 deletions(-)
@spytheman has helped me out before on this repo...maybe he knows quickly what broke it?
Still trying to look at this.
@Ccode-lang that PR above works for this issue if you need an immediate workaround. Otherwise, I'm sure there's an error in my code somewhere.
Ok thank you. 👍
using this only gives an error message that says:
vsh.v:18:8: warning: module 'io' is imported but never used
16 | import os { input, exec, user_os, join_path home_dir }
17 | import term.ui as tui
18 | import io
| ~~
19 |
20 | struct Vsh {
vsh.v:275:5: warning: unused variable: `cmd_args`
273 | is_builtin := cmd.split(' ')[0]
274 | // get the rest of the string which will be the args
275 | cmd_args := cmd.split(' ')[1..]
| ~~~~~~~~
276 | match is_builtin {
277 | // only use the first arg since you can't be in two dirs at once
vsh.v:16:20: error: module `os` has no constant or function `exec`
14 | */
15 |
16 | import os { input, exec, user_os, join_path home_dir }
| ~~~~
17 | import term.ui as tui
18 | import io
vsh.v:285:19: error: unknown function: os.exec
283 | // run the command the user entered
284 | // TODO: move this all to a function and make it more resilient
285 | output := os.exec(cmd) or {
| ~~~~~~~~~
286 | buffer.put('\n$err')
287 | buffer.put('v# ')
vsh.v:299:28: error: `void` type has no fields
297 |
298 | // display it's output
299 | buffer.put('\n$output.output')
| ~~~~~~
300 |
301 | // return the prompt so another command can be entered
i'll open pull to fix this
Using your version of v still opens the broken prompt it must be an error in the code somewhere.
It seems like the event()
function is not getting executed in a loop.
Yes, I just tried your PR, #25 and the issue still exists. Let me play with what you've put together and I'll see if I can track down the issue.
Ok 👍
It seems like the event() function is not getting executed in a loop.
Well, some of the other events in the loop work. If you press down a bunch of times, it works fine. I think the issue is related term.ui and/or os modules. I have workarounds but not a permanent fix. I'll push what I have for some unrelated parts though to simply updating the code for the recent v changes.
Ok, I will try it now
the issue is still there but you said there were workarounds. what are they exactly?
Yeah, I know. I haven't been able to crack it yet.
Workarounds are here:
https://github.com/vlang/v/pull/10569#issuecomment-881912000
You can also use os.system
but it's not useful since it only returns a return code...Though this may be the place to look to see why os.execute
hangs up
ok thanks!
I found also running v -o vsh.c vsh.v && gcc -o vsh vsh.c
worked better than building with v.
how do you kill the run thou. It keeps trying to track my mouse after running
nevermind found it out
found using this file with modified v worked vsh.txt
I'll open a pull with it to make a temporary fix