Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh support + macOS fixes #10

Closed
wants to merge 3 commits into from
Closed

Conversation

jasonmadigan
Copy link

@jasonmadigan jasonmadigan commented May 7, 2024

  • Took a stab at a zsh provider
  • Fixed a bug where shell's spawned, with zsh + macOS, would hang after an exit command.

Before:
before

After:

after

Testing:

cargo run example.yaml example.cast --overwrite --shell zsh

@k9withabone
Copy link
Owner

Thanks for the PR! In your GIFs, I don't think you are using your new zsh shell option. The --shell option defaults to bash on all platforms.

@jasonmadigan
Copy link
Author

@k9withabone ah, yes, I'd updated (and not checked in) example.yaml with the shell overridden in settings:. it does seem to work ($SHELL is set to /bin/zsh).

I'll test it with bash elsewhere too.

@k9withabone
Copy link
Owner

I'd updated (and not checked in) example.yaml with the shell overridden in settings:. it does seem to work ($SHELL is set to /bin/zsh).

Got it, thanks for the clarification.

Copy link
Owner

@k9withabone k9withabone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good overall. I'm just a bit confused about setting the SIGINT handler.

src/config/spawn.rs Outdated Show resolved Hide resolved
src/config/spawn.rs Outdated Show resolved Hide resolved
@jasonmadigan jasonmadigan force-pushed the main branch 2 times, most recently from 752a723 to 8d5a79c Compare May 7, 2024 14:34
@jasonmadigan jasonmadigan marked this pull request as ready for review May 7, 2024 14:37
@jasonmadigan jasonmadigan force-pushed the main branch 9 times, most recently from 7ff2cf0 to 29d8ce7 Compare May 8, 2024 17:25
@jasonmadigan jasonmadigan marked this pull request as draft May 10, 2024 09:05
@jasonmadigan jasonmadigan marked this pull request as ready for review May 14, 2024 19:24
@jasonmadigan
Copy link
Author

@k9withabone Have a patch for quit for macOS which seems to consistently fix. Still not 100% why, but the spawned process doesn't exit on macOS until some bytes are read from the process prior to exit.

@k9withabone
Copy link
Owner

Huh, that's interesting. I'll try setting up a container to see if that applies to zsh on Linux as well.

Just out of curiosity, how did you figure that out?

@jasonmadigan
Copy link
Author

Huh, that's interesting. I'll try setting up a container to see if that applies to zsh on Linux as well.

Just out of curiosity, how did you figure that out?

Wish it was glamorous, but it was mostly stepping through the debugger a lot to see if some error was being swallowed, I noticed if I read buffer output things worked. Bit of a strange one!

@k9withabone
Copy link
Owner

I'll try setting up a container to see if that applies to zsh on Linux as well.

Looks like it works on Linux too! The only problem now is that seems to be echoing the command.

Here's the asciicast I got when running the example with zsh:

{"version": 2, "width": 128, "height": 30, "timestamp": 1715890488, "duration": 13.201686, "title": "autocast example", "env": {"GOODBYE": "Goodbye!", "TERM": "xterm", "HELLO": "", "SHELL": "/usr/bin/zsh"}}
[0.000000, "o", "[example]$ "]
[0.100000, "o", "e"]
[0.200000, "o", "c"]
[0.300000, "o", "h"]
[0.400000, "o", "o"]
[0.500000, "o", " "]
[0.600000, "o", "$"]
[0.700000, "o", "H"]
[0.800000, "o", "E"]
[0.900000, "o", "L"]
[1.000000, "o", "L"]
[1.100000, "o", "O"]
[1.200000, "o", "\r\n"]
[1.200077, "o", "e\bec"]
[1.200122, "o", "ho "]
[1.200155, "o", "$HE"]
[1.200181, "o", "LL"]
[1.200187, "o", "O"]
[1.200210, "o", "\u001b[?2004l\r\r\n"]
[1.200276, "o", "\r\n"]
[1.200298, "o", "\u001b[1m\u001b[7m#\u001b[27m\u001b[1m\u001b[0m                                                                                                                               \r \r"]
[1.200317, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J"]
[1.200322, "o", "[example]$ "]
[3.300322, "o", "n"]
[3.400322, "o", "a"]
[3.500322, "o", "n"]
[3.600322, "o", "o"]
[3.700322, "o", "\r\n"]
[3.700392, "o", "n\bnano"]
[3.700447, "o", "\u001b[?2004l\r\r\n"]
[3.707589, "o", "\u001b[?2004h"]
[3.707695, "o", "\u001b[?1049h\u001b[22;0;0t\u001b[1;30r\u001b(B\u001b[m\u001b[4l\u001b[?7h\u001b[39;49m\u001b[?1h\u001b="]
[3.707778, "o", "\u001b[?1h\u001b=\u001b[?25l"]
[3.708167, "o", "\u001b[39;49m\u001b(B\u001b[m\u001b[H\u001b[2J"]
[3.708261, "o", "\u001b(B\u001b[0;7m  GNU nano 7.2 \u001b[46bNew Buffer \u001b[55b \u001b[1;127H\u001b(B\u001b[m"]
[3.708305, "o", "\u001b[28;40H\u001b(B\u001b[0;7m[ Welcome to nano.  For basic help, type Ctrl+G. ]\u001b(B\u001b[m"]
[3.708372, "o", "\r\u001b[29d\u001b(B\u001b[0;7m^G\u001b(B\u001b[m Help\u001b[29;17H\u001b(B\u001b[0;7m^O\u001b(B\u001b[m Write Out    \u001b(B\u001b[0;7m^W\u001b(B\u001b[m Where Is     \u001b(B\u001b[0;7m^K\u001b(B\u001b[m Cut\u001b[29;65H\u001b(B\u001b[0;7m^T\u001b(B\u001b[m Execute\t\u001b(B\u001b[0;7m^C\u001b(B\u001b[m Location     \u001b(B\u001b[0;7mM-U\u001b(B\u001b[m Undo\u001b[29;113H"]
[3.708402, "o", "\u001b(B\u001b[0;7mM-A\u001b(B\u001b[m Set Mark\r\u001b[30d\u001b(B\u001b[0;7m^X\u001b(B\u001b[m Exit\u001b[30;17H\u001b(B\u001b[0;7m^R\u001b(B\u001b[m Read File    \u001b(B\u001b[0;7m^\\\u001b(B\u001b[m Replace\t\u001b(B\u001b[0;7m^U\u001b(B\u001b[m Paste\u001b[30;65H"]
[3.708436, "o", "\u001b(B\u001b[0;7m^J\u001b(B\u001b[m Justify\t\u001b(B\u001b[0;7m^/\u001b(B\u001b[m Go To Line   \u001b(B\u001b[0;7mM-E\u001b(B\u001b[m Redo\u001b[30;113H\u001b(B\u001b[0;7mM-6\u001b(B\u001b[m Copy"]
[3.708562, "o", "\r\u001b[2d\u001b[?12l\u001b[?25h"]
[5.900564, "o", "\u001b[?25l\u001b[1;119H\u001b(B\u001b[0;7mModified\u001b(B\u001b[m"]
[5.900605, "o", "\u001b[?12l\u001b[?25h"]
[5.900624, "o", "\r\u001b[2dh"]
[6.000590, "o", "\u001b[?25l\u001b[?12l\u001b[?25he"]
[6.100501, "o", "\u001b[?25l"]
[6.100579, "o", "\u001b[?12l\u001b[?25hl"]
[6.200599, "o", "\u001b[?25l\u001b[?12l\u001b[?25hl"]
[6.300579, "o", "\u001b[?25l\u001b[?12l\u001b[?25ho"]
[8.500485, "o", "\u001b[?25l"]
[8.500573, "o", "\r\u001b[28d"]
[8.500594, "o", "\u001b(B\u001b[0;7mSave modified buffer? \u001b[105b \u001b[29;1H"]
[8.500614, "o", " Y\u001b(B\u001b[m Yes\u001b[K\r\u001b[30d\u001b(B\u001b[0;7m N\u001b(B\u001b[m No  \u001b[30;18H"]
[8.500634, "o", "\u001b(B\u001b[0;7mC\u001b(B\u001b[m Cancel\u001b[K\u001b[28;23H\u001b[?12l\u001b[?25h"]
[9.700551, "o", "\u001b[?25l"]
[9.700639, "o", "\r\u001b[J\u001b[30d\u001b[?12l\u001b[?25h\u001b[30;1H\u001b[?1049l\u001b[23;0;0t\r\u001b[?1l\u001b>\u001b[?2004l"]
[9.701357, "o", "\u001b[1m\u001b[7m#\u001b[27m\u001b[1m\u001b[0m                                                                                                                               \r \r\r\u001b[0m\u001b[27m\u001b[24m\u001b[J"]
[9.701384, "o", "[example]$ "]
[9.801384, "o", "e"]
[9.901384, "o", "c"]
[10.001384, "o", "h"]
[10.101384, "o", "o"]
[10.201384, "o", " "]
[10.301384, "o", "$"]
[10.401384, "o", "G"]
[10.501384, "o", "O"]
[10.601384, "o", "O"]
[10.701384, "o", "D"]
[10.801384, "o", "B"]
[10.901384, "o", "Y"]
[11.001384, "o", "E"]
[11.101384, "o", "\r\n"]
[11.101491, "o", "e\becho"]
[11.101571, "o", " $GOODBYE"]
[11.101586, "o", "\u001b[?2004l\r\r\n"]
[11.101640, "o", "Goodbye!\r\n"]
[11.101685, "o", "\u001b[1m\u001b[7m#\u001b[27m\u001b[1m\u001b[0m                                                                                                                               \r \r\r\u001b[0m\u001b[27m\u001b[24m\u001b[J"]
[11.101686, "o", "[example]$ "]
[13.201686, "o", "\r\n"]

There's some other weird output in there too.

For comparison here's the example when run with bash:

{"version": 2, "width": 128, "height": 30, "timestamp": 1715890421, "duration": 13.201402, "title": "autocast example", "env": {"SHELL": "/usr/bin/bash", "TERM": "xterm", "HELLO": "", "GOODBYE": "Goodbye!"}}
[0.000000, "o", "[example]$ "]
[0.100000, "o", "e"]
[0.200000, "o", "c"]
[0.300000, "o", "h"]
[0.400000, "o", "o"]
[0.500000, "o", " "]
[0.600000, "o", "$"]
[0.700000, "o", "H"]
[0.800000, "o", "E"]
[0.900000, "o", "L"]
[1.000000, "o", "L"]
[1.100000, "o", "O"]
[1.200000, "o", "\r\n"]
[1.200253, "o", "\r\n"]
[1.200291, "o", "[example]$ "]
[3.300291, "o", "n"]
[3.400291, "o", "a"]
[3.500291, "o", "n"]
[3.600291, "o", "o"]
[3.700291, "o", "\r\n"]
[3.706029, "o", "\u001b[?2004h"]
[3.706140, "o", "\u001b[?1049h\u001b[22;0;0t\u001b[1;30r\u001b(B\u001b[m\u001b[4l\u001b[?7h\u001b[39;49m\u001b[?1h\u001b="]
[3.706193, "o", "\u001b[?1h\u001b=\u001b[?25l"]
[3.706676, "o", "\u001b[39;49m\u001b(B\u001b[m\u001b[H\u001b[2J"]
[3.706719, "o", "\u001b(B\u001b[0;7m  GNU nano 7.2                                               New Buffer                                                         \u001b[1;127H\u001b(B\u001b[m"]
[3.706782, "o", "\u001b[28;40H\u001b(B\u001b[0;7m[ Welcome to nano.  For basic help, type Ctrl+G. ]\u001b(B\u001b[m"]
[3.706824, "o", "\r\u001b[29d\u001b(B\u001b[0;7m^G\u001b(B\u001b[m Help\u001b[29;17H"]
[3.706880, "o", "\u001b(B\u001b[0;7m^O\u001b(B\u001b[m Write Out    \u001b(B\u001b[0;7m^W\u001b(B\u001b[m Where Is     \u001b(B\u001b[0;7m^K\u001b(B\u001b[m Cut\u001b[29;65H\u001b(B\u001b[0;7m^T\u001b(B\u001b[m Execute\t\u001b(B\u001b[0;7m^C\u001b(B\u001b[m Location     \u001b(B\u001b[0;7mM-U\u001b(B\u001b[m Undo\u001b[29;113H\u001b(B\u001b[0;7mM-A\u001b(B\u001b[m Set Mark\r\u001b[30d\u001b(B\u001b[0;7m^X\u001b(B\u001b[m Exit\u001b[30;17H"]
[3.706914, "o", "\u001b(B\u001b[0;7m^R\u001b(B\u001b[m Read File    \u001b(B\u001b[0;7m^\\\u001b(B\u001b[m Replace\t\u001b(B\u001b[0;7m^U\u001b(B\u001b[m Paste\u001b[30;65H\u001b(B\u001b[0;7m^J\u001b(B\u001b[m Justify\t\u001b(B\u001b[0;7m^/\u001b(B\u001b[m Go To Line   \u001b(B\u001b[0;7mM-E\u001b(B\u001b[m Redo\u001b[30;113H\u001b(B\u001b[0;7mM-6\u001b(B\u001b[m Copy"]
[3.706956, "o", "\r\u001b[2d\u001b[?12l\u001b[?25h"]
[5.900563, "o", "\u001b[?25l\u001b[1;119H\u001b(B\u001b[0;7mModified\u001b(B\u001b[m"]
[5.900602, "o", "\u001b[?12l\u001b[?25h"]
[5.900618, "o", "\r\u001b[2dh"]
[6.000431, "o", "\u001b[?25l"]
[6.000473, "o", "\u001b[?12l\u001b[?25h"]
[6.000508, "o", "e"]
[6.100445, "o", "\u001b[?25l"]
[6.100485, "o", "\u001b[?12l\u001b[?25hl"]
[6.200427, "o", "\u001b[?25l"]
[6.200483, "o", "\u001b[?12l\u001b[?25hl"]
[6.300425, "o", "\u001b[?25l"]
[6.300472, "o", "\u001b[?12l\u001b[?25ho"]
[8.500432, "o", "\u001b[?25l"]
[8.500607, "o", "\r\u001b[28d\u001b(B\u001b[0;7mSave modified buffer?                                                                                                           \u001b[29;1H Y\u001b(B\u001b[m Yes\u001b[K\r\u001b[30d\u001b(B\u001b[0;7m N\u001b(B\u001b[m No  \u001b[30;18H\u001b(B\u001b[0;7mC\u001b(B\u001b[m Cancel\u001b[K\u001b[28;23H\u001b[?12l\u001b[?25h"]
[9.700433, "o", "\u001b[?25l"]
[9.700533, "o", "\r"]
[9.700557, "o", "\u001b[J\u001b[30d\u001b[?12l\u001b[?25h\u001b[30;1H\u001b[?1049l\u001b[23;0;0t\r\u001b[?1l\u001b>"]
[9.700572, "o", "\u001b[?2004l"]
[9.701168, "o", "[example]$ "]
[9.801168, "o", "e"]
[9.901168, "o", "c"]
[10.001168, "o", "h"]
[10.101168, "o", "o"]
[10.201168, "o", " "]
[10.301168, "o", "$"]
[10.401168, "o", "G"]
[10.501168, "o", "O"]
[10.601168, "o", "O"]
[10.701168, "o", "D"]
[10.801168, "o", "B"]
[10.901168, "o", "Y"]
[11.001168, "o", "E"]
[11.101168, "o", "\r\n"]
[11.101344, "o", "Goodbye!\r\n"]
[11.101402, "o", "[example]$ "]
[13.201402, "o", "\r\n"]

@k9withabone k9withabone added bug Something isn't working enhancement New feature or request labels May 17, 2024
@k9withabone k9withabone added this to the v0.1.1 milestone May 17, 2024
@k9withabone
Copy link
Owner

Doesn't look like your most recent change made a difference. Does PROMPT_COMMAND work the same for zsh as it does for bash? I can't find a reference to it in the zsh man pages.

@jasonmadigan
Copy link
Author

@k9withabone apols, I've been away for a few weeks so not really had much time to dig into this until now. I'm seeing the same odd behaviour as you on zsh on macOS too.

@k9withabone
Copy link
Owner

It's all good. I've been busy with other things as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants