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

Abiltity to specify command to run in SSH command #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

joehoyle
Copy link
Member

See #16

@joehoyle
Copy link
Member Author

@rmccue in conjunction with https://github.com/humanmade/vantage-backend/pull/1733 I had an initial pass at this. Even with the ability to specify a different command though, we still get the exec-sandbox leading output no matter what, so I had to resort to trimming the initial lines.

Comment on lines +121 to +127
// If this is the first output chunk and we're in porcelain mode, strip the initial 2 lines
// this contain somethign like:
// exec sudo sandbox-exec 'clear; $command'
// sh-4.2$ exec sudo sandbox-exec 'clear; $command'
if ( porcelain && firstOutput ) {
data = data.split( '\n' ).slice(2).join('\n').trim();
}
Copy link
Member

Choose a reason for hiding this comment

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

Something you can do here is use the clear itself; it outputs the ANSI control characters for clearing, so you can split on that. Even cleaner, change the backend command to output just the one code with something like

exec sudo sandbox-exec "printf '\033[2J'; $command"

And then here, data.split( '033[2J', 2 )[1]

Comment on lines +129 to +132
// Strip the ANSI escape codes if we're in porcelain mode.
if ( porcelain ) {
data = data.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
}
Copy link
Member

Choose a reason for hiding this comment

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

This isn't really safe to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants