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

Fix escaping of shell commands #7

Merged

Conversation

Gabriella439
Copy link
Contributor

Before this change, the hotel executable wouldn't handle spaces in arguments correctly. A simple example is:

$ hotel exec echo ' a'

Before this change that would print:

a

… and after this change it correctly prints:

 a

src/HotelCalifornia/Exec.hs Outdated Show resolved Hide resolved
@@ -38,15 +39,18 @@ parseExecArgs = do
runExecArgs :: ExecArgs -> IO ()
runExecArgs ExecArgs {..} = do
let script =
unwords $ NEL.toList execArgsScript
Escape.escapeMany $ NEL.toList execArgsScript
Copy link
Owner

Choose a reason for hiding this comment

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

beautiful thank you 🙏🏻

Before this change, the `hotel` executable wouldn't handle spaces in
arguments correctly.  A simple example is:

```bash
$ hotel exec echo ' a'
```

Before this change that would print:

```
a
```

… and after this change it correctly prints:

```
 a
```
@parsonsmatt
Copy link
Owner

Fixes #10

… for when the user wants to run an arbitrary shell command

This also fixes the command-line parser so that you don't need
to add `--` before the command to avoid confusing options.
@Gabriella439
Copy link
Contributor Author

I added support for a --shell option and also fixed it so that you don't need to add -- before the command as a precaution

Copy link
Owner

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

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

This is fantastic. Thanks so much!!

@Gabriella439
Copy link
Contributor Author

Note that I can't merge so you'll have to merge this

@parsonsmatt parsonsmatt merged commit a5e16c6 into parsonsmatt:master Sep 15, 2023
3 checks passed
@parsonsmatt
Copy link
Owner

Released as 0.0.2.0, thank you!

@Gabriella439 Gabriella439 deleted the gabriella/fix_escaping branch September 15, 2023 18:07
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